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

docs(fields): Json filterMode() #285

Merged
merged 1 commit into from
Nov 10, 2023
Merged
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
39 changes: 38 additions & 1 deletion resources/views/pages/ru/fields/json.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
title="Json"
:sectionMenu="[
'Разделы' => [
['url' => '#basics', 'label' => 'Основы'],
['url' => '#key-value', 'label' => 'Ключ/Значение'],
['url' => '#fields', 'label' => 'Набор полей'],
['url' => '#value-only', 'label' => 'Только значение'],
['url' => '#default', 'label' => 'Значение по умолчанию'],
['url' => '#creatable-removable', 'label' => 'Добавление/удаление'],
['url' => '#vertical', 'label' => 'Вертикальное отображение'],
['url' => '#relation', 'label' => 'Отношения через Json'],
['url' => '#filter', 'label' => 'Фильтр'],
]
]"
>

<x-sub-title id="basics">Make</x-sub-title>

<x-p>
Поле <em>Json</em> включает в себя все базовые методы.
</x-p>
Expand Down Expand Up @@ -142,6 +146,8 @@ public function fields(): array

<x-code language="php">
use MoonShine\Fields\Json;
use MoonShine\Fields\Switcher;
use MoonShine\Fields\Text;

//...

Expand Down Expand Up @@ -261,7 +267,10 @@ public function fields(): array
</x-code>

<x-code language="php">
use MoonShine\Fields\ID;
use MoonShine\Fields\Json;
use MoonShine\Fields\Relationships\BelongsTo;
use MoonShine\Fields\Text;

//...

Expand All @@ -280,7 +289,7 @@ public function fields(): array
Text::make('Text')->required(),
]) // [tl! focus:end]
->creatable()
->removable(),
->removable()
];
}

Expand All @@ -295,4 +304,32 @@ public function fields(): array
<x-image theme="light" src="{{ asset('screenshots/json_relation.png') }}"></x-image>
<x-image theme="dark" src="{{ asset('screenshots/json_relation_dark.png') }}"></x-image>

<x-sub-title id="filter">Фильтр</x-sub-title>

<x-p>
Если поле используется для построения фильтра, то необходимо воспользоваться методом <code>filterMode()</code>.
Данный метод адаптирует поведение поля и устанавливает <code>creatable = false</code>.
</x-p>

<x-code language="php">
use MoonShine\Fields\Json;
use MoonShine\Fields\Text;

//...

public function filters(): array
{
return [
Json::make('Data')
->fields([
Text::make('Title', 'title'),
Text::make('Value', 'value')
])
->filterMode() // [tl! focus]
];
}

//...
</x-code>

</x-page>