ShowroomController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Showroom;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class ShowroomController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Showroom(), function (Grid $grid) {
  18. $grid->model()->orderByDesc('sort');
  19. $grid->column('id')->sortable();
  20. $grid->column('name');
  21. $grid->column('sort')->editable();
  22. $grid->column('is_opened')->switch();
  23. $grid->filter(function (Grid\Filter $filter) {
  24. $filter->panel();
  25. $filter->like('name')->width(2);
  26. });
  27. });
  28. }
  29. /**
  30. * Make a show builder.
  31. *
  32. * @param mixed $id
  33. *
  34. * @return Show
  35. */
  36. protected function detail($id)
  37. {
  38. return Show::make($id, new Showroom(), function (Show $show) {
  39. $show->field('id');
  40. $show->field('name');
  41. $show->field('sort');
  42. $show->field('is_opened');
  43. $show->field('created_at');
  44. $show->field('updated_at');
  45. });
  46. }
  47. /**
  48. * Make a form builder.
  49. *
  50. * @return Form
  51. */
  52. protected function form()
  53. {
  54. return Form::make(new Showroom(), function (Form $form) {
  55. $form->display('id');
  56. $form->text('name')->required();
  57. $form->number('sort');
  58. $form->radio('is_opened')
  59. ->options(config('global.bool_status'))
  60. ->default(1);
  61. $form->disableViewButton();
  62. $form->disableDeleteButton();
  63. $form->disableListButton();
  64. $form->disableEditingCheck();
  65. $form->disableViewCheck();
  66. $form->disableCreatingCheck();
  67. });
  68. }
  69. }