WithdrawController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Withdraw;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WithdrawController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Withdraw(), function (Grid $grid) {
  18. $grid->model()->with('userData')->orderByDesc('id');
  19. $grid->column('id')->sortable();
  20. $grid->column('userData.name','昵称')->sortable();
  21. $grid->column('userData.avatar','昵称')->image('',40,40);
  22. $grid->column('userData.mobile','手机号')->sortable();
  23. $grid->column('type')->using(Withdraw::$label)
  24. ->dot(
  25. [
  26. 2 => 'primary',
  27. 1 => 'success',
  28. 3 => 'danger',
  29. ],
  30. 'danger' // 第二个参数为默认值
  31. );
  32. $grid->column('bank_name');
  33. $grid->column('name');
  34. $grid->column('number');
  35. $grid->column('state')->using(Withdraw::$state)
  36. ->dot(
  37. [
  38. 0 => 'primary',
  39. 1 => 'success',
  40. 2 => 'danger',
  41. ],
  42. 'danger' // 第二个参数为默认值
  43. );;
  44. // $grid->column('user_id');
  45. $grid->column('amount');
  46. $grid->column('procedure');
  47. $grid->column('practical_amount');
  48. $grid->column('not_desc');
  49. $grid->column('created_at');
  50. $grid->column('updated_at')->sortable();
  51. $grid->disableDeleteButton();
  52. $grid->disableCreateButton();
  53. $grid->disableViewButton();
  54. $grid->filter(function (Grid\Filter $filter) {
  55. $filter->panel();
  56. $filter->equal('state')->select(Withdraw::$state);
  57. $filter->between('created_at')->datetime();
  58. });
  59. });
  60. }
  61. /**
  62. * Make a show builder.
  63. *
  64. * @param mixed $id
  65. *
  66. * @return Show
  67. */
  68. protected function detail($id)
  69. {
  70. return Show::make($id, new Withdraw(), function (Show $show) {
  71. $show->field('id');
  72. $show->field('type');
  73. $show->field('bank_name');
  74. $show->field('name');
  75. $show->field('number');
  76. $show->field('state');
  77. $show->field('user_id');
  78. $show->field('amount');
  79. $show->field('procedure');
  80. $show->field('practical_amount');
  81. $show->field('not_desc');
  82. $show->field('created_at');
  83. $show->field('updated_at');
  84. });
  85. }
  86. /**
  87. * Make a form builder.
  88. *
  89. * @return Form
  90. */
  91. protected function form()
  92. {
  93. return Form::make(new Withdraw(), function (Form $form) {
  94. $state = Withdraw::$state;
  95. // unset($state[0]);
  96. $form->display('id');
  97. // $form->select('type')->options(Withdraw::$label)->disable();
  98. $form->select('state')
  99. ->when(2, function (Form $form) {
  100. $form->textarea('not_desc');
  101. })
  102. ->options($state);
  103. $form->display('amount');
  104. $form->display('procedure');
  105. $form->display('practical_amount');
  106. $form->display('created_at');
  107. $form->display('updated_at');
  108. });
  109. }
  110. }