model()->orderBy('id', 'desc'); $grid->column('id', __('ID'))->sortable(); $grid->column('title', __('文章名稱')); $grid->column('lang', __('语言'))->display(function ($title) { if ($title == 'en') { return "英文"; }else { return "中文"; } }); $grid->column('type', __('类型'))->display(function ($title) { if ($title == 1) { return "公告"; }elseif($title == 2){ return "常见问题"; } else { return "教程"; } }); $grid->column('created_at', __('创建时间'))->sortable(); $grid->actions(function ($actions) { // 去掉查看 $actions->disableView(); }); return $grid; } /** * Make a form builder. * * @return Form */ protected function form() { $form = new Form(new Articles()); $form->text('title', __('文章标题')); $form->select('lang', __('语言'))->options(['en'=> '英语','zh' => '中文']); $form->select('type', __('类型'))->options([1=> '公告',2 => '常见问题',3=> '教程']); $form->ckeditor('content'); return $form; } }