链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.5 KiB

  1. <?php
  2. namespace App\Admin\Controllers\v3;
  3. use App\Admin\Repositories\v3\CouponSetting;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Controllers\AdminController;
  8. use App\Models\v3\CouponSetting as SettingModel;
  9. class CouponSettingController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make(new CouponSetting(), function (Grid $grid) {
  19. $grid->id->sortable();
  20. $grid->category_text;
  21. $grid->name;
  22. $grid->value;
  23. $grid->sort;
  24. $grid->status->switch();
  25. $grid->model()->orderBy('id','desc');
  26. $grid->filter(function (Grid\Filter $filter) {
  27. // $categoryList = SettingModel::$category;
  28. $filter->like('name');
  29. // $filter->equal('category')->select($categoryList);
  30. });
  31. $grid->disableRowSelector();
  32. });
  33. }
  34. /**
  35. * Make a show builder.
  36. *
  37. * @param mixed $id
  38. *
  39. * @return Show
  40. */
  41. protected function detail($id)
  42. {
  43. return Show::make($id, new CouponSetting(), function (Show $show) {
  44. $show->row(function (Show\Row $show) {
  45. $show->width(6)->id;
  46. $show->width(6)->category_text;
  47. $show->width(6)->name;
  48. $show->width(6)->value;
  49. });
  50. $show->row(function (Show\Row $show) {
  51. $show->width(6)->sort;
  52. $show->width(6)->status_text;
  53. $show->width(6)->created_at;
  54. $show->width(6)->updated_at;
  55. });
  56. // $show->desc;
  57. });
  58. }
  59. /**
  60. * Make a form builder.
  61. *
  62. * @return Form
  63. */
  64. protected function form()
  65. {
  66. return Form::make(new CouponSetting(), function (Form $form) {
  67. $form->hidden('id');
  68. $form->select('category')->width(6)->options(SettingModel::$category);
  69. $form->text('name')->width(6)->required()->maxLength(50);
  70. $form->number('value')->required()->rules('min:1')->default(1);
  71. // $form->text('desc')->maxLength(500);
  72. $form->number('sort')->rules('min:0');
  73. $form->disableResetButton();
  74. $form->disableViewCheck();
  75. $form->disableEditingCheck();
  76. $form->disableCreatingCheck();
  77. });
  78. }
  79. }