header('APP首页管理'); $content->description('列表'); $content->body($this->grid()); }); } /** * Edit interface. * * @param $id * @return Content */ public function edit($id) { return Admin::content(function (Content $content) use ($id) { $content->header('APP首页管理'); $content->description('编辑'); $content->body($this->form()->edit($id)); }); } /** * Create interface. * * @return Content */ public function create() { return Admin::content(function (Content $content) { $content->header('APP首页管理'); $content->description('新增'); $content->body($this->form()); }); } /** * Make a grid builder. * * @return Grid */ protected function grid() { return Admin::grid(App_index_pic::class, function (Grid $grid) { $grid->id('序号')->sortable(); $grid->column('pic', '显示的图片')->display(function ($pic){ return""; }); $grid->column('pic_link_url', '跳转的地址')->editable(); $grid->column('create_id', '创建者')->display(function ($value){ $name = Administrator::where('id',$value)->pluck('name')->first(); return $name; }); $grid->column('update_id', '更新者')->display(function ($value){ $name = Administrator::where('id',$value)->pluck('name')->first(); return $name; });; $grid->created_at('创建时间'); $grid->updated_at('修改时间'); $grid->disableExport(); }); } /** * Make a form builder. * * @return Form */ protected function form() { return Admin::form(App_index_pic::class, function (Form $form) { $form->display('id', '序号'); $form->image('pic','显示的图片')->uniqueName(); $form->url('pic_link_url','跳转的页面'); $form->display('update_id', '更新者')->with(function ($value){ if($value){ }else{ $value=Admin::user()->id; } $name = Administrator::where('id',$value)->pluck('name')->first(); return $name; }); $form->display('create_id', '创建者')->with(function ($value){ if($value){ }else{ $value=Admin::user()->id; } $name = Administrator::where('id',$value)->pluck('name')->first(); return $name; }); $form->hidden('create_id')->default(Admin::user()->id); //保存前回调 $form->saving(function (Form $form) { $form->update_id =Admin::user()->id; }); $form->display('created_at', '创建时间'); $form->display('updated_at', '更新时间'); }); } }