UserWithdrawController.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace App\Admin\Controllers\Share;
  3. use App\Admin\Actions\Grid\WithdrawReview;
  4. use App\Models\UserWithdraw;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. class UserWithdrawController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make(UserWithdraw::with('user'), function (Grid $grid) {
  19. $grid->column('id')->sortable();
  20. $grid->column('avatar', '基本信息')->display(function () {
  21. $str = "";
  22. $str .= "<div style='margin-right:10px;display: flex;align-items: center'>";
  23. $str .= '<img data-action="preview-img" src="' . $this->avatar . '" style="height:50px;width:50px;cursor:pointer;margin-right:10px;" class="img img-thumbnail">';
  24. $str .= '<div>';
  25. $str .= '<p style="margin-bottom: 5px">' . $this->nickname . '</p>';
  26. $str .= "</div>";
  27. $str .= "</div>";
  28. return $str;
  29. });
  30. $grid->column('name');
  31. $grid->column('phone_num');
  32. $grid->column('type')->using(config('global.withdraw_type'))
  33. ->label(['default','primary','success','info']);
  34. $grid->column('account');
  35. $grid->column('price');
  36. $grid->column('discount');
  37. $grid->column('real','实际打款金额')->display(function (){
  38. return $this->price - $this->discount;
  39. });
  40. $grid->column('status','状态')
  41. ->using(config('global.withdraw_status'))
  42. ->label(['default','primary','success','danger'])
  43. ;
  44. $grid->column('created_at','申请时间');
  45. $grid->column('review_at','审核时间');
  46. $grid->column('withdraw_at','打款时间');
  47. $grid->actions(function (Grid\Displayers\Actions $actions) {
  48. if ($actions->row->status != 2) {
  49. $actions->append(new WithdrawReview(UserWithdraw::class, $actions->row->id, $actions->row->status));
  50. }
  51. });
  52. $grid->filter(function (Grid\Filter $filter) {
  53. $filter->panel();
  54. $filter->between('created_at','申请时间')->date()->width(3);
  55. $filter->equal('status','状态')->select(config('global.withdraw_status'))->width(3);
  56. $filter->like('nickname','昵称')->width(2);
  57. $filter->like('name','姓名')->width(2);
  58. $filter->equal('mobile','手机号')->width(2);
  59. });
  60. $grid->disableCreateButton();
  61. $grid->disableEditButton();
  62. $grid->disableViewButton();
  63. });
  64. }
  65. /**
  66. * Make a show builder.
  67. *
  68. * @param mixed $id
  69. *
  70. * @return Show
  71. */
  72. protected function detail($id)
  73. {
  74. return Show::make($id, new UserWithdraw(), function (Show $show) {
  75. $show->field('id');
  76. $show->field('user_id');
  77. $show->field('name');
  78. $show->field('type');
  79. $show->field('account');
  80. $show->field('price');
  81. $show->field('desc');
  82. $show->field('status');
  83. $show->field('created_at');
  84. $show->field('updated_at');
  85. });
  86. }
  87. /**
  88. * Make a form builder.
  89. *
  90. * @return Form
  91. */
  92. protected function form()
  93. {
  94. return Form::make(new UserWithdraw(), function (Form $form) {
  95. $form->display('id');
  96. $form->text('user_id');
  97. $form->text('name');
  98. $form->text('type');
  99. $form->text('account');
  100. $form->text('price');
  101. $form->text('desc');
  102. $form->text('status');
  103. $form->display('created_at');
  104. $form->display('updated_at');
  105. });
  106. }
  107. }