SystemConfigController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\SystemConfig;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class SystemConfigController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new SystemConfig(), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('title');
  20. $grid->column('key');
  21. $grid->column('value');
  22. $grid->column('info');
  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. $grid->actions(function (Grid\Displayers\Actions $actions) {
  30. $actions->disableDelete();
  31. });
  32. //批量操作
  33. $grid->batchActions(function (Grid\Tools\BatchActions $batch) {
  34. $batch->disableDelete();
  35. });
  36. });
  37. }
  38. /**
  39. * Make a show builder.
  40. *
  41. * @param mixed $id
  42. *
  43. * @return Show
  44. */
  45. protected function detail($id)
  46. {
  47. return Show::make($id, new SystemConfig(), function (Show $show) {
  48. $show->field('id');
  49. $show->field('title');
  50. $show->field('key');
  51. $show->field('value');
  52. $show->field('info');
  53. $show->field('created_at');
  54. $show->field('updated_at');
  55. });
  56. }
  57. /**
  58. * Make a form builder.
  59. *
  60. * @return Form
  61. */
  62. protected function form()
  63. {
  64. return Form::make(new SystemConfig(), function (Form $form) {
  65. $form->display('id');
  66. $form->text('title');
  67. $form->text('key');
  68. $form->text('value');
  69. $form->text('info');
  70. $form->display('created_at');
  71. $form->display('updated_at');
  72. });
  73. }
  74. }