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

feat: Добавлена документация к полю MorphTo #521

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/screenshots/morph_to_array.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/screenshots/morph_to_array_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 28 additions & 3 deletions resources/views/pages/en/fields/morph_to.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,37 @@ public function fields(): array
//...
</x-code>

<x-image theme="light" src="{{ asset('screenshots/morph_to.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/morph_to_dark.png') }}"></x-image>
<x-moonshine::alert type="default" icon="heroicons.information-circle">
Required <code>types</code> method indicating the available classes.<br/>
The key is a reference to the model, and the value is the field to display.
</x-moonshine::alert>

<x-image theme="light" src="{{ asset('screenshots/morph_to.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/morph_to_dark.png') }}"></x-image>
<x-p>Description of the value of the <code>types</code> method:</x-p>
<x-p>The key is a reference to the model<br>
The value is a string or an array.
<x-moonshine::alert type="default" icon="heroicons.information-circle">
If the value is passed as a string, it should indicate the name of the field to be displayed. If it is passed as an array, then the first element of the array is the name of the field to display, and the second is the name of the relationship instead of the name of the model.
</x-moonshine::alert>
</x-p>

<x-code>
use MoonShine\Fields\Relationships\MorphTo; // [tl! focus]

//...

public function fields(): array
{
return [
MorphTo::make('Imageable')->types([
Company::class => ['short_name', 'Organization']
]), // [tl! focus:-2]
];
}
//...
</x-code>

<x-image theme="light" src="{{ asset('screenshots/morph_to_array.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/morph_to_array_dark.png') }}"></x-image>

</x-page>
33 changes: 29 additions & 4 deletions resources/views/pages/ru/fields/morph_to.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,37 @@ public function fields(): array
//...
</x-code>

<x-image theme="light" src="{{ asset('screenshots/morph_to.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/morph_to_dark.png') }}"></x-image>
<x-moonshine::alert type="default" icon="heroicons.information-circle">
Обязательный метод <code>types</code> с указанием доступных классов.<br/>
Ключ — ссылка на модель, а значение — поле для отображения.
Обязательный метод <code>types</code> с указанием доступных классов.
</x-moonshine::alert>

<x-image theme="light" src="{{ asset('screenshots/morph_to.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/morph_to_dark.png') }}"></x-image>
<x-p>Описание значения метода <code>types</code>:</x-p>
<x-p>Ключ — ссылка на модель<br>
Значение - строка или массив.<br>
<x-moonshine::alert type="default" icon="heroicons.information-circle">
Если значение передаётся как строка, то она должна указывать на название поля, которое нужно отобразить. Если же передаётся как массив, то первый элемент массива — это название поля для отображения, а второй — имя отношения вместо названия модели.
</x-moonshine::alert>
</x-p>

<x-code>
use MoonShine\Fields\Relationships\MorphTo; // [tl! focus]

//...

public function fields(): array
{
return [
MorphTo::make('Imageable')->types([
Company::class => ['short_name', 'Organization']
]), // [tl! focus:-2]
];
}
//...
</x-code>

<x-image theme="light" src="{{ asset('screenshots/morph_to_array.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/morph_to_array_dark.png') }}"></x-image>

</x-page>
Loading