WxShopGoodsProductController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace App\Admin\Controllers\Shop;
  3. use App\Admin\Repositories\Shop\WxShopGoodsProduct;
  4. use App\Wen\Utils\Settings;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. class WxShopGoodsProductController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. $app_coin_name = Settings::get('app_coin_name', '硬币');
  19. return Grid::make(new WxShopGoodsProduct(), function (Grid $grid) use ($app_coin_name){
  20. $grid->simplePaginate();
  21. $grid->model()->orderBy('id', 'desc');
  22. $grid->column('id')->sortable();
  23. $grid->column('pic');
  24. $grid->column('param_value');
  25. $grid->column('vip_price')->display(function ($v) use ($app_coin_name){
  26. if($this->credit_type == 1){
  27. return '¥'.$v;
  28. }else{
  29. return $v.$app_coin_name;
  30. }
  31. })->sortable();
  32. $grid->column('price')->display(function ($v) use ($app_coin_name){
  33. if($this->credit_type == 1){
  34. return '¥'.$v;
  35. }else{
  36. return $v.$app_coin_name;
  37. }
  38. })->sortable();
  39. $grid->column('stock');
  40. $grid->column('sort');
  41. $grid->column('goods_id');
  42. $grid->column('state');
  43. $grid->column('created_at');
  44. $grid->column('updated_at')->sortable();
  45. $grid->filter(function (Grid\Filter $filter) {
  46. $filter->equal('id');
  47. });
  48. });
  49. }
  50. /**
  51. * Make a show builder.
  52. *
  53. * @param mixed $id
  54. *
  55. * @return Show
  56. */
  57. protected function detail($id)
  58. {
  59. return Show::make($id, new WxShopGoodsProduct(), function (Show $show) {
  60. $show->field('id');
  61. $show->field('pic');
  62. $show->field('param_value');
  63. $show->field('vip_price');
  64. $show->field('price');
  65. $show->field('stock');
  66. $show->field('sort');
  67. $show->field('goods_id');
  68. $show->field('state');
  69. $show->field('created_at');
  70. $show->field('updated_at');
  71. });
  72. }
  73. /**
  74. * Make a form builder.
  75. *
  76. * @return Form
  77. */
  78. protected function form()
  79. {
  80. return Form::make(new WxShopGoodsProduct(), function (Form $form) {
  81. $form->display('id');
  82. $form->text('pic');
  83. $form->text('param_value');
  84. $form->text('vip_price');
  85. $form->text('price');
  86. $form->text('stock');
  87. $form->text('sort');
  88. $form->text('goods_id');
  89. $form->text('state');
  90. $form->deleting(function (Form $form){
  91. global $__MINI_GLOBAL_TENANT_ID__;
  92. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  93. return $form->response()->error('权限不足,不可以删除其他分站对象');
  94. }
  95. });
  96. });
  97. }
  98. }