123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace App\Admin\Controllers;
- use App\Admin\Controllers\RowAction\CustomAction;
- use App\Models\ScaleCategory;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Show;
- /**
- * 量表分类,控制器
- */
- class ScaleCategoryController extends AdminController
- {
- /**
- * Title for current resource.
- *
- * @var string
- */
- // protected $title = '量表分类';
- protected $title = '心理评估分类';
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new ScaleCategory());
- // // 禁用创建按钮
- // $grid->disableCreateButton();
- // // 禁用编辑功能
- // $grid->disableActions();
- // 新增过滤筛选
- $grid->filter(function ($filter) {
- $filter->like('name', '分类名称');
- $filter->like('info', '分类首页简介');
- $filter->like('list_info', __('分类列表简介'));
- });
- $grid->column('id', __('Id'));
- $grid->column('name', __('分类名称'));
- $grid->column('info', __('分类首页简介'));
- $grid->column('list_info', __('分类列表简介'));
- $grid->column('rank', __('排序 越大越前'));
- $grid->column('is_index', __('是否首页'))->display(function ($isIndex){
- return isset(ScaleCategory::isIndexMap[$isIndex])
- ?
- ScaleCategory::isIndexMap[$isIndex]
- :
- ""
- ;
- });
- $grid->column('created_at', __('创建时间'));
- $grid->column('updated_at', __('更新时间'));
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(ScaleCategory::findOrFail($id));
- $show->field('id', __('Id'));
- $show->field('name', __('Name'));
- $show->field('info', __('Info'));
- $show->field('list_info', __('List Info'));
- $show->field('pic', __('Pic'));
- $show->field('rank', __('Rank'));
- $show->field('created_at', __('Created at'));
- $show->field('updated_at', __('Updated at'));
- $show->field('deleted_at', __('Deleted at'));
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new ScaleCategory());
- $form->text('name', __('分类名称'));
- $form->text('info', __('分类首页简介'));
- $form->select('pid', __('上级分类'))->options(ScaleCategory::where('deleted_at', null)->pluck('name', 'id'))->default(0);
- $form->text('list_info', __('分类列表简介'));
- $form->image('pic', __('首页图片'));
- $form->image('pic2', __('分类图片'));
- $form->number('rank', __('排序 越大越前'));
- $form->radio("is_index","是否首页")
- ->options(ScaleCategory::isIndexMap)
- ->default(ScaleCategory::isIndexNo)
- ;
- return $form;
- }
- }
|