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

134 lines
3.6 KiB

  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\Coupon;
  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\Coupon as couponModel;
  9. class CouponController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make($c = new Coupon(), function (Grid $grid) {
  19. $grid->id->sortable();
  20. $grid->title;
  21. $grid->start_time->display(function($time){
  22. return date('Y-m-d H:i:s',$time);
  23. });
  24. $grid->end_time->display(function($time){
  25. return date('Y-m-d H:i:s',$time);
  26. });
  27. $grid->full_amount;
  28. $grid->discounts;
  29. $grid->discount_type;
  30. $grid->inventory;
  31. $grid->inventory_use;
  32. $grid->type;
  33. $grid->active_type;
  34. $grid->status
  35. ->using(
  36. config('coupon.status')
  37. )
  38. ->label(
  39. config('coupon.status_label')
  40. );
  41. // $grid->usable_start_time->display(function($time){
  42. // return date('Y-m-d H:i:s',$time);
  43. // });
  44. // $grid->usable_end_time->display(function($time){
  45. // return date('Y-m-d H:i:s',$time);
  46. // });
  47. $grid->filter(function (Grid\Filter $filter) {
  48. $filter->like('name');
  49. });
  50. });
  51. }
  52. /**
  53. * Make a show builder.
  54. *
  55. * @param mixed $id
  56. *
  57. * @return Show
  58. */
  59. protected function detail($id)
  60. {
  61. return Show::make($id, new Coupon(), function (Show $show) {
  62. $show->id;
  63. $show->title;
  64. $show->introduce;
  65. $show->start_time;
  66. $show->end_time;
  67. $show->full_amount;
  68. $show->discounts;
  69. $show->is_new_user;
  70. $show->inventory;
  71. $show->inventory_use;
  72. $show->type;
  73. $show->market_id;
  74. $show->storetype_id;
  75. $show->category;
  76. $show->active_type;
  77. $show->status;
  78. $show->remark;
  79. $show->weigh;
  80. $show->usable_number;
  81. $show->usable_start_time;
  82. $show->usable_end_time;
  83. $show->discount_type;
  84. $show->created_at;
  85. $show->updated_at;
  86. });
  87. }
  88. /**
  89. * Make a form builder.
  90. *
  91. * @return Form
  92. */
  93. protected function form()
  94. {
  95. return Form::make(new Coupon(), function (Form $form) {
  96. $form->display('id');
  97. $form->text('title');
  98. $form->text('introduce');
  99. $form->text('start_time');
  100. $form->text('end_time');
  101. $form->text('full_amount');
  102. $form->text('discounts');
  103. $form->text('is_new_user');
  104. $form->text('inventory');
  105. $form->text('inventory_use');
  106. $form->text('type');
  107. $form->text('market_id');
  108. $form->text('storetype_id');
  109. $form->text('category');
  110. $form->text('active_type');
  111. $form->text('status');
  112. $form->text('remark');
  113. $form->text('weigh');
  114. $form->text('usable_number');
  115. $form->text('usable_start_time');
  116. $form->text('usable_end_time');
  117. $form->text('discount_type');
  118. $form->display('created_at');
  119. $form->display('updated_at');
  120. });
  121. }
  122. }