链街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.

86 lines
2.3 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. $filter->like('name');
  28. });
  29. });
  30. }
  31. /**
  32. * Make a show builder.
  33. *
  34. * @param mixed $id
  35. *
  36. * @return Show
  37. */
  38. protected function detail($id)
  39. {
  40. return Show::make($id, new CouponSetting(), function (Show $show) {
  41. $show->row(function (Show\Row $show) {
  42. $show->width(6)->id;
  43. $show->width(6)->category_text;
  44. $show->width(6)->name;
  45. $show->width(6)->value;
  46. });
  47. $show->row(function (Show\Row $show) {
  48. $show->width(6)->sort;
  49. $show->width(6)->status_text;
  50. $show->width(6)->created_at;
  51. $show->width(6)->updated_at;
  52. });
  53. // $show->desc;
  54. });
  55. }
  56. /**
  57. * Make a form builder.
  58. *
  59. * @return Form
  60. */
  61. protected function form()
  62. {
  63. return Form::make(new CouponSetting(), function (Form $form) {
  64. $form->hidden('id');
  65. $form->select('category')->width(6)->options(SettingModel::$category);
  66. $form->text('name')->width(6)->required()->maxLength(50);
  67. $form->number('value')->required()->rules('min:1')->default(1);
  68. // $form->text('desc')->maxLength(500);
  69. $form->number('sort')->rules('min:0');
  70. $form->disableResetButton();
  71. $form->disableViewCheck();
  72. $form->disableEditingCheck();
  73. $form->disableCreatingCheck();
  74. });
  75. }
  76. }