DocumentController.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Document;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class DocumentController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Document(), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('title');
  20. $grid->column('en_title');
  21. $grid->column('content')->limit(50);
  22. $grid->column('en_content')->limit(50);
  23. // $grid->column('created_at');
  24. // $grid->column('updated_at')->sortable();
  25. $grid->filter(function (Grid\Filter $filter) {
  26. $filter->equal('id');
  27. });
  28. });
  29. }
  30. /**
  31. * Make a show builder.
  32. *
  33. * @param mixed $id
  34. *
  35. * @return Show
  36. */
  37. protected function detail($id)
  38. {
  39. return Show::make($id, new Document(), function (Show $show) {
  40. $show->field('id');
  41. $show->field('title');
  42. $show->field('en_title');
  43. $show->field('content')->unescape();
  44. $show->field('en_content')->unescape();
  45. $show->field('created_at');
  46. $show->field('updated_at');
  47. });
  48. }
  49. /**
  50. * Make a form builder.
  51. *
  52. * @return Form
  53. */
  54. protected function form()
  55. {
  56. return Form::make(new Document(), function (Form $form) {
  57. $form->display('id');
  58. $form->text('title');
  59. $form->text('en_title');
  60. $form->editor('content');
  61. $form->editor('en_content');
  62. $form->display('created_at');
  63. $form->display('updated_at');
  64. $form->footer(function ($footer) {
  65. // 去掉`查看`checkbox
  66. $footer->disableViewCheck();
  67. // 去掉`继续编辑`checkbox
  68. $footer->disableEditingCheck();
  69. // 去掉`继续创建`checkbox
  70. $footer->disableCreatingCheck();
  71. });
  72. });
  73. }
  74. }