UserWithdrawController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\UserWithdraw;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class UserWithdrawController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new UserWithdraw(), function (Grid $grid) {
  18. $grid->model()->with(['user'])->orderBy('id','desc');
  19. $grid->column('id')->sortable();
  20. $grid->column('user_id','名称')->display(function () {
  21. return $this->user->nickname;
  22. });
  23. $grid->column('phone_num','手机号')->display(function () {
  24. return $this->user->phone_num;
  25. });
  26. $grid->column('price','提现金额');
  27. $grid->column('account','提现账号');
  28. $grid->column('created_at','申请时间')->sortable();
  29. $grid->column('desc','备注');
  30. $grid->column('status','状态')
  31. ->using([0=> '待审核',1 => '已通过', 2 => '已拒绝'])
  32. ->dot(
  33. [
  34. 1 => 'success',
  35. 2 => 'danger',
  36. ],
  37. 'primary' // 第二个参数为默认值
  38. );
  39. $grid->disableDeleteButton();
  40. $grid->disableCreateButton();
  41. $grid->disableBatchActions();
  42. $grid->disableRowSelector();
  43. $grid->filter(function (Grid\Filter $filter) {
  44. $filter->equal('id');
  45. });
  46. });
  47. }
  48. /**
  49. * Make a show builder.
  50. *
  51. * @param mixed $id
  52. *
  53. * @return Show
  54. */
  55. protected function detail($id)
  56. {
  57. return Show::make($id, new UserWithdraw(), function (Show $show) {
  58. $show->field('id');
  59. $show->field('user_id');
  60. $show->field('name');
  61. $show->field('type');
  62. $show->field('account');
  63. $show->field('price');
  64. $show->field('desc');
  65. $show->field('status');
  66. $show->field('created_at');
  67. $show->field('updated_at');
  68. });
  69. }
  70. /**
  71. * Make a form builder.
  72. *
  73. * @return Form
  74. */
  75. protected function form()
  76. {
  77. return Form::make(new UserWithdraw(), function (Form $form) {
  78. $form->display('name');
  79. $form->display('account');
  80. $form->display('price');
  81. $form->display('desc');
  82. $form->switch('status', '通过?')->default(1);
  83. $form->display('created_at');
  84. $form->display('updated_at');
  85. });
  86. }
  87. }