Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc blocks for resources #7

Merged
merged 1 commit into from
Jun 22, 2022
Merged

Conversation

seralexs
Copy link
Contributor

some phpDoc for ResourceСontract and Resource base class

Copy link
Collaborator

@lee-to lee-to left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Спасибо! Круто, есть пара мелочей

public function title(): string;

/**
* Define a field, which will be used in relations as a foreign key
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не ключ а поле которое будет отображаться в отношениях во view (скажем если это Select и связь со странанми то отображаем название страны и к примеру это поле name) foreign key мы берем автоматом из отношения

src/Contracts/Resources/ResourceContract.php Show resolved Hide resolved
src/Contracts/Resources/ResourceContract.php Show resolved Hide resolved
/**
* Check whether user can perform action on model
*
* @param string $ability create/update/delete/massDelete
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view, viewAny, restore, forceDelete

/**
* Creates a form element class: Field,Filter
*
* @param ...$arguments $label Form element label will be displayed in moonshine admin panel,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь бы по подробнее, смотри что за аргументы
$label = тут все ясно form element label
$field = Поле в таблице либо метод отношений если это поле для реализации отношения
$resource = Если это реализация отношения то служит для указания titleField, либо можно передать сам ресурс в котором указан titleField, либо можно передать функцию и задать titleField более подробно
BelongsTo::make('Страна', 'country', fn(Model $item) => $item->id . ' ' . $item->name)

@lee-to lee-to merged commit d38263d into moonshine-software:1.x Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants