Skip to content

Commit

Permalink
docs(resources): modifyListComponent, modifyFormComponent and modifyD…
Browse files Browse the repository at this point in the history
…etailComponent methods
  • Loading branch information
DissNik committed Aug 14, 2024
1 parent 4053240 commit 9662e65
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
38 changes: 38 additions & 0 deletions resources/views/pages/en/resources/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
['url' => '#redirects', 'label' => 'Redirects'],
['url' => '#active_actions', 'label' => 'Active actions'],
['url' => '#actions', 'label' => 'Buttons'],
['url' => '#modification', 'label' => 'Modification'],
['url' => '#components', 'label' => 'Components'],
['url' => '#boot', 'label' => 'Boot'],
]
Expand Down Expand Up @@ -336,6 +337,43 @@ public function actions(): array
}
</x-code>

<x-sub-title id="modification">Modification</x-sub-title>

<x-p>
To modify the main <strong>IndexPage</strong>, <strong>FormPage</strong> or <strong>DetailPage</strong> component
pages from a resource, you can override the corresponding <code>modifyListComponent()</code>,
<code>modifyFormComponent()</code> and <code>modifyDetailComponent()</code> methods.
</x-p>

<x-code language="php">
public function modifyListComponent(MoonShineRenderable $component): MoonShineRenderable
{
return parent::modifyListComponent($component)->customAttributes([
'data-my-attr' => 'value'
]);
}
</x-code>

<x-code language="php">
public function modifyFormComponent(MoonShineRenderable $component): MoonShineRenderable
{
return parent::modifyFormComponent($component)->fields([
FlexibleRender::make('Top'),
...parent::modifyFormComponent($component)->getFields()->toArray(),
FlexibleRender::make('Bottom'),
])->submit('Go');
}
</x-code>

<x-code language="php">
public function modifyDetailComponent(MoonShineRenderable $component): MoonShineRenderable
{
return parent::modifyDetailComponent($component)->customAttributes([
'data-my-attr' => 'value'
]);
}
</x-code>

<x-sub-title id="components">Components</x-sub-title>

<x-p>
Expand Down
38 changes: 38 additions & 0 deletions resources/views/pages/ru/resources/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
['url' => '#redirects', 'label' => 'Редиректы'],
['url' => '#active_actions', 'label' => 'Активные действия'],
['url' => '#actions', 'label' => 'Кнопки'],
['url' => '#modification', 'label' => 'Модификация'],
['url' => '#components', 'label' => 'Компоненты'],
['url' => '#boot', 'label' => 'Boot'],
]
Expand Down Expand Up @@ -336,6 +337,43 @@ public function actions(): array
}
</x-code>

<x-sub-title id="modification">Модификация</x-sub-title>

<x-p>
Для модификации основного компонента <strong>IndexPage</strong>, <strong>FormPage</strong> или <strong>DetailPage</strong>
страницы из ресурса можно переопределить соответствующие методы <code>modifyListComponent()</code>,
<code>modifyFormComponent()</code> и <code>modifyDetailComponent()</code>.
</x-p>

<x-code language="php">
public function modifyListComponent(MoonShineRenderable $component): MoonShineRenderable
{
return parent::modifyListComponent($component)->customAttributes([
'data-my-attr' => 'value'
]);
}
</x-code>

<x-code language="php">
public function modifyFormComponent(MoonShineRenderable $component): MoonShineRenderable
{
return parent::modifyFormComponent($component)->fields([
FlexibleRender::make('Top'),
...parent::modifyFormComponent($component)->getFields()->toArray(),
FlexibleRender::make('Bottom'),
])->submit('Go');
}
</x-code>

<x-code language="php">
public function modifyDetailComponent(MoonShineRenderable $component): MoonShineRenderable
{
return parent::modifyDetailComponent($component)->customAttributes([
'data-my-attr' => 'value'
]);
}
</x-code>

<x-sub-title id="components">Компоненты</x-sub-title>

<x-p>
Expand Down

0 comments on commit 9662e65

Please sign in to comment.