diff --git a/resources/views/pages/en/resources/index.blade.php b/resources/views/pages/en/resources/index.blade.php index a619df37..9a726330 100644 --- a/resources/views/pages/en/resources/index.blade.php +++ b/resources/views/pages/en/resources/index.blade.php @@ -10,6 +10,7 @@ ['url' => '#modal', 'label' => 'Modal windows'], ['url' => '#redirects', 'label' => 'Redirects'], ['url' => '#active_actions', 'label' => 'Active actions'], + ['url' => '#actions', 'label' => 'Buttons'], ['url' => '#components', 'label' => 'Components'], ['url' => '#boot', 'label' => 'Boot'], ] @@ -271,6 +272,7 @@ public function redirectAfterDelete(): string class PostResource extends ModelResource { //... + public function getActiveActions(): array // [tl! focus:start] { return ['create', 'view', 'update', 'delete', 'massDelete']; @@ -280,6 +282,60 @@ public function getActiveActions(): array // [tl! focus:start] } +Buttons + + + By default, the model resource index page only has a button to create.
+ The actions() method allows you to add additional buttons. +
+ + +namespace MoonShine\Resources; + +class PostResource extends ModelResource +{ + //... + + public function actions(): array // [tl! focus:start] + { + return [ + ActionButton::make('Refresh', '#') + ->dispatchEvent(AlpineJs::event(JsEvent::TABLE_UPDATED, 'index-table')) + ]; + } // [tl! focus:end] + + //... +} + + + + + + You can also change the display of the buttons, + display them in a line or in a drop-down menu to save space. + + + +namespace MoonShine\Resources; + +class PostResource extends ModelResource +{ + //... + + public function actions(): array + { + return [ + ActionButton::make('Button 1', '/') + ->showInLine(), // [tl! focus] + ActionButton::make('Button 2', '/') + ->showInDropdown() // [tl! focus] + ]; + } // [tl! focus:end] + + //... +} + + Components diff --git a/resources/views/pages/ru/resources/index.blade.php b/resources/views/pages/ru/resources/index.blade.php index 2dbf5404..4f50dd1a 100644 --- a/resources/views/pages/ru/resources/index.blade.php +++ b/resources/views/pages/ru/resources/index.blade.php @@ -10,6 +10,7 @@ ['url' => '#modal', 'label' => 'Модальные окна'], ['url' => '#redirects', 'label' => 'Редиректы'], ['url' => '#active_actions', 'label' => 'Активные действия'], + ['url' => '#actions', 'label' => 'Кнопки'], ['url' => '#components', 'label' => 'Компоненты'], ['url' => '#boot', 'label' => 'Boot'], ] @@ -271,6 +272,7 @@ public function redirectAfterDelete(): string class PostResource extends ModelResource { //... + public function getActiveActions(): array // [tl! focus:start] { return ['create', 'view', 'update', 'delete', 'massDelete']; @@ -280,7 +282,61 @@ public function getActiveActions(): array // [tl! focus:start] } -Components +Кнопки + + + По умолчанию на индексной странице ресурса модели присутствует только кнопка для создания.
+ Метод actions() позволяет добавить дополнительные кнопки. +
+ + +namespace MoonShine\Resources; + +class PostResource extends ModelResource +{ + //... + + public function actions(): array // [tl! focus:start] + { + return [ + ActionButton::make('Refresh', '#') + ->dispatchEvent(AlpineJs::event(JsEvent::TABLE_UPDATED, 'index-table')) + ]; + } // [tl! focus:end] + + //... +} + + + + + + Вы также можете изменить отображение кнопок, + отображать их в линию или же в выпадающем меню для экономии места. + + + +namespace MoonShine\Resources; + +class PostResource extends ModelResource +{ + //... + + public function actions(): array + { + return [ + ActionButton::make('Button 1', '/') + ->showInLine(), // [tl! focus] + ActionButton::make('Button 2', '/') + ->showInDropdown() // [tl! focus] + ]; + } // [tl! focus:end] + + //... +} + + +Компоненты Лучший способ изменять компоненты страниц это опубликовать страницы