filter(function(\Encore\Admin\Grid\Filter $filter){ // 在这里添加字段过滤器 $filter->like('name', '名称'); $filter->expand(); }); $grid->column('id', __('Id')); $grid->column('drill_id', __('训练'))->display(function ($id) { if ($id > 0){ $mentalityDrillData = MentalityDrill::find($id); if ($mentalityDrillData){ return $mentalityDrillData->title; } } return ''; }); $grid->column('name', __('名称')); $grid->column('time', __('时长')); $grid->column('type', __('类别'))->display(function ($type) { return MentalityDrillExtend::$typeMap[$type]; }); $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(MentalityDrillExtend::findOrFail($id)); $show->field('id', __('Id')); $show->field('drill_id', __('Drill id')); $show->field('name', __('Name')); $show->field('time', __('Time')); $show->field('src', __('Src')); $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 MentalityDrillExtend()); $select = MentalityDrill::get(['id','title as name'])->pluck('name','id'); $form->select('drill_id', __('训练'))->options($select)->required(); $form->select('type', __('类别'))->options(MentalityDrillExtend::$typeMap)->required(); $form->text('name', __('名称'))->required(); $form->text('time', __('时长'))->required(); $form->file('src', __('音视频'))->removable()->uniqueName()->move('videos/'.date('Y').'/'.date('m')); $form->image('pic', __('背景图片')); return $form; } }