Skip to content

Commit

Permalink
Merge pull request #521 from forest-lynx/morph-to
Browse files Browse the repository at this point in the history
feat: Добавлена документация к полю MorphTo
  • Loading branch information
DissNik authored Jul 23, 2024
2 parents 0f3c510 + 10c6df7 commit 8f505fe
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
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>

0 comments on commit 8f505fe

Please sign in to comment.