SettingController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Setting;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class SettingController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Setting(), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('name');
  20. $grid->column('logo');
  21. $grid->column('created_at');
  22. $grid->column('updated_at')->sortable();
  23. $grid->filter(function (Grid\Filter $filter) {
  24. $filter->equal('id');
  25. });
  26. });
  27. }
  28. /**
  29. * Make a show builder.
  30. *
  31. * @param mixed $id
  32. *
  33. * @return Show
  34. */
  35. protected function detail($id)
  36. {
  37. return Show::make($id, new Setting(), function (Show $show) {
  38. $show->field('id');
  39. $show->field('name');
  40. $show->field('logo');
  41. $show->field('created_at');
  42. $show->field('updated_at');
  43. });
  44. }
  45. /**
  46. * Make a form builder.
  47. *
  48. * @return Form
  49. */
  50. protected function form()
  51. {
  52. return Form::make(new Setting(), function (Form $form) {
  53. $form->display('id');
  54. $form->text('name');
  55. $form->text('logo');
  56. $form->display('created_at');
  57. $form->display('updated_at');
  58. });
  59. }
  60. }