WxRefundController.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\WxRefund;
  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 WxRefundController 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 WxRefund(), function (Grid $grid) use ($app_coin_name){
  20. $grid->simplePaginate();
  21. $grid->model()->orderBy('id', 'desc');
  22. $grid->column('id')->sortable();
  23. $grid->column('user_id');
  24. $grid->column('order_good_id');
  25. $grid->column('order_id');
  26. $grid->column('goods_id');
  27. $grid->column('product_id');
  28. $grid->column('amount');
  29. $grid->column('amount')->display(function ($v) use ($app_coin_name){
  30. if($this->credit_type == 1){
  31. return '¥'.$v;
  32. }else{
  33. return $v.$app_coin_name;
  34. }
  35. })->sortable();
  36. $grid->column('created_at');
  37. $grid->column('updated_at')->sortable();
  38. $grid->filter(function (Grid\Filter $filter) {
  39. $filter->equal('id');
  40. });
  41. $grid->disableBatchActions();
  42. $grid->disableActions();
  43. $grid->disableCreateButton();
  44. });
  45. }
  46. /**
  47. * Make a show builder.
  48. *
  49. * @param mixed $id
  50. *
  51. * @return Show
  52. */
  53. protected function detail($id)
  54. {
  55. return Show::make($id, new WxRefund(), function (Show $show) {
  56. $show->field('id');
  57. $show->field('user_id');
  58. $show->field('order_good_id');
  59. $show->field('order_id');
  60. $show->field('goods_id');
  61. $show->field('product_id');
  62. $show->field('amount');
  63. $show->field('created_at');
  64. $show->field('updated_at');
  65. });
  66. }
  67. /**
  68. * Make a form builder.
  69. *
  70. * @return Form
  71. */
  72. protected function form()
  73. {
  74. return Form::make(new WxRefund(), function (Form $form) {
  75. $form->display('id');
  76. $form->text('user_id');
  77. $form->text('order_good_id');
  78. $form->text('order_id');
  79. $form->text('goods_id');
  80. $form->text('product_id');
  81. $form->text('amount');
  82. $form->display('created_at');
  83. $form->display('updated_at');
  84. $form->deleting(function (Form $form){
  85. global $__MINI_GLOBAL_TENANT_ID__;
  86. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  87. return $form->response()->error('权限不足,不可以删除其他分站对象');
  88. }
  89. });
  90. });
  91. }
  92. }