12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Repositories\SiteAlbumFolder;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- use Dcat\Admin\Layout\Content;
- use Dcat\Admin\Admin;
- class SiteAlbumFolderController extends AdminController
- {
- /**
- * page index
- */
- public function index(Content $content)
- {
- return $content
- ->header(admin_trans( 'admin.folder'))
- ->body($this->grid());
- }
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new SiteAlbumFolder(), function (Grid $grid) {
- $grid->column('id')->sortable();
- $grid->column('title')->display(function ($title) {
- $level = $this->level; // 获取当前行的 level 字段值
- $prefix = str_repeat(' ', $level * 2). ' <i class="fa fa-angle-right"></i> '; // 生成 level * 3 个加号
- return $prefix . ' ' . html_entity_decode($title); // 拼接加号和名称
- });;
- $grid->column('parent_id');
- $grid->column('order')->sortable();
- $grid->column('enabled')->switch();
- $grid->column('created_at')->sortable();
- $grid->disableViewButton();
- $grid->showQuickEditButton();
- $grid->enableDialogCreate();
- $grid->disableEditButton();
- $grid->disablePerPages();
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new SiteAlbumFolder(), function (Form $form) {
- $form->select('parent_id', admin_trans_field('parent'))
- ->options(SiteAlbumFolder::selectMainOptions())
- ->saving(function ($v) {
- return (int) $v;
- });
- $form->text('title')->required();
- $form->radio('folder_type')
- ->options(admin_trans_array(config('dictionary.folder_type')))
- ->default(0)->required();
- $form->listbox('show_tabs')->options(admin_trans_array([
- '0' => 'cover',
- '1' => 'en_detail',
- '2' => 'cn_detail',
- '3' => 'video',
- '4' => 'poster',
- '5' => 'cert',
- '6' => 'pdf',
- ]))->default([0, 1, 2, 3, 4, 5, 6])->saving(function ($v) { return json_encode($v); });
- $form->number('order')
- ->default(0)
- ->rules('numeric');
- $form->switch('enabled')->default(1);
- });
- }
- }
|