12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace App\Admin\Controllers;
- use App\Models\Document;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class DocumentController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new Document(), function (Grid $grid) {
- $grid->column('id')->sortable();
- $grid->column('title');
- $grid->column('en_title');
- $grid->column('content')->limit(50);
- $grid->column('en_content')->limit(50);
- // $grid->column('created_at');
- // $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new Document(), function (Show $show) {
- $show->field('id');
- $show->field('title');
- $show->field('en_title');
- $show->field('content')->unescape();
- $show->field('en_content')->unescape();
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new Document(), function (Form $form) {
- $form->display('id');
- $form->text('title');
- $form->text('en_title');
- $form->editor('content');
- $form->editor('en_content');
- $form->display('created_at');
- $form->display('updated_at');
- $form->footer(function ($footer) {
- // 去掉`查看`checkbox
- $footer->disableViewCheck();
- // 去掉`继续编辑`checkbox
- $footer->disableEditingCheck();
- // 去掉`继续创建`checkbox
- $footer->disableCreatingCheck();
- });
- });
- }
- }
|