123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?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()
- {
- $grid = new Grid(new Document());
- $grid->model()->orderBy('id','desc');
- $grid->column('id')->sortable();
- $grid->column('title');
- // $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
- $filter->like('title','标题');
- });
- //操作管理
- $grid->actions(function (Grid\Displayers\Actions $actions) {
- if ($actions->row->id == 1 || $actions->row->id == 2) {
- $actions->disableDelete();
- }
- });
- return $grid;
- }
- /**
- * 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('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->editor('content');
- $form->display('created_at');
- $form->display('updated_at');
- });
- }
- }
|