Last active
March 24, 2023 09:23
-
-
Save AlexanderKomkov/099109863b3c62fd196d2f965687d406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Repositories\Manager\Content\Resource\Resources\Settings; | |
use App\Repositories\Manager\Content\Resource\Resources\Resource; | |
use App\Repositories\Manager\Manager; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Tabs\Tab; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Actions\Edit; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Actions\Copy; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Actions\Activate; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Actions\Delete; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Actions\Restore; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Actions\ForceDelete; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Fields\ID; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Fields\Boolean; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Fields\Text; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Fields\Integer; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Fields\Select; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Fields\Route; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Fields\Separator; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Filters\Text as TextFilter; | |
use App\Repositories\Manager\Content\Resource\Libs\Form\Filters\Select as SelectFilter; | |
class MenuResource extends Resource | |
{ | |
/** @var string **/ | |
public static $model = 'App\\Menu'; | |
/** @var integer **/ | |
public static $sort = 10; | |
/** @var string **/ | |
public static $route = 'menus'; | |
/** @var array **/ | |
public static $with = [ | |
'menuType' | |
]; | |
/** @var array **/ | |
public static $cache = [ | |
'main_menu', | |
'buyer_menu', | |
'catalog_menu', | |
'store_menu', | |
'mobile_main_menu', | |
'basket_menu', | |
'profile_menu', | |
'auth_menu', | |
'manager_sidebar_menus' | |
]; | |
/** @var string **/ | |
public static $group = 'settings'; | |
/** | |
* Get the actions displayed by the resource. | |
* | |
* @return array | |
*/ | |
public function actions() | |
{ | |
return [ | |
Edit::make(), | |
Copy::make(), | |
Activate::make(), | |
Delete::make(), | |
Restore::make(), | |
ForceDelete::make(), | |
]; | |
} | |
/** | |
* Filters. | |
* | |
* @return array | |
*/ | |
public function filters() | |
{ | |
return [ | |
TextFilter::make('name'), | |
SelectFilter::make('menu_type_id')->optionsFromModel('App\\MenuType'), | |
SelectFilter::make('published')->boolean(), | |
]; | |
} | |
/** | |
* Get the fields displayed by the index resource. | |
* | |
* @return array | |
*/ | |
public function fieldsForIndex() | |
{ | |
return [ | |
Text::make('name')->sortOnIndex(10), | |
Select::make('menuType')->formatIndex('menu_type')->showOnIndex()->sortOnIndex(20), | |
Route::make()->showOnIndex()->sortOnIndex(30), | |
Integer::make('sort')->showOnIndex()->sortOnIndex(40), | |
Boolean::make('published')->sortOnIndex(50), | |
ID::make()->sortOnIndex(60), | |
]; | |
} | |
/** | |
* Get the fields displayed by the detail resource. | |
* | |
* @return array | |
*/ | |
public function fieldsForDetail() | |
{ | |
return [ | |
Tab::make('menu')->fields([ | |
Text::make('name'), | |
Boolean::make('published'), | |
Integer::make('sort'), | |
Separator::make('main'), | |
Route::make(), | |
Route::make('active_route')->formatDetail('active_routes'), | |
Text::make('htmlclass'), | |
Select::make('menuType')->formatDetail('menu_type') | |
]) | |
]; | |
} | |
/** | |
* Get the fields displayed by the resource. | |
* | |
* @return array | |
*/ | |
public function fields() | |
{ | |
return [ | |
Tab::make('menu')->fields([ | |
ID::make(), | |
Boolean::make('published'), | |
Text::make('name')->required(), | |
Integer::make('sort')->default(500)->classForm('col-8 col-sm-4 col-lg-3')->required(), | |
Separator::make('main'), | |
Route::make()->required(), | |
Route::make('active_route')->multiple(), | |
Text::make('htmlclass'), | |
Select::make('menu_type_id')->optionsFromModel('App\\MenuType')->required() | |
]) | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment