ShareUserController.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\User;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class ShareUserController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new User(), function (Grid $grid) {
  18. $grid->model()->withCount('invite_data')->where('is_share', 1)->orderByDesc('id');
  19. $grid->column('id')->sortable();
  20. $grid->column('share_name', '分销商姓名');
  21. $grid->column('share_phone', '分销商电话');
  22. $grid->column('last_login_ip', '最后登录IP');
  23. $grid->column('last_login_time', '最后登录时间');
  24. $grid->column('is_black', '是否拉黑')->switch();
  25. $grid->column('diamond', '剩余次数');
  26. $grid->column('income', '可提现佣金');
  27. $grid->column('invite_data_count', '已邀请人数');
  28. $grid->column('created_at');
  29. $grid->column('updated_at')->sortable();
  30. $grid->quickSearch(['name', 'id', 'mobile'])->placeholder('搜索...');
  31. $grid->filter(function (Grid\Filter $filter) {
  32. $filter->panel();
  33. $filter->equal('id');
  34. $filter->like('share_phone');
  35. $filter->between('created_at')->datetime();
  36. });
  37. $grid->disableCreateButton();
  38. $grid->disableDeleteButton();
  39. });
  40. }
  41. /**
  42. * Make a show builder.
  43. *
  44. * @return Show
  45. */
  46. protected function detail($id)
  47. {
  48. return Show::make($id, new User(), function (Show $show) {
  49. $show->model()->with('userShare');
  50. $show->field('id');
  51. $show->field('name');
  52. $show->field('open_id', '微信openid');
  53. $show->field('avatar')->image();
  54. $show->field('mobile');
  55. $show->field('online');
  56. $show->field('last_login_ip');
  57. $show->field('last_login_time');
  58. $show->field('is_black')->as(function ($item) {
  59. return $item ? '拉黑' : '正常';
  60. });
  61. $show->field('diamond');
  62. $show->field('is_share')->as(function ($item) {
  63. return $item ? '是推广人' : '不是推广人';
  64. });
  65. $show->field('share_name');
  66. $show->field('share_phone');
  67. $show->field('userShare.name', '推广人昵称(被)');
  68. $show->field('share_date');
  69. $show->field('income');
  70. $show->field('qr_code')->image();
  71. $show->field('created_at');
  72. $show->field('updated_at');
  73. $show->disableDeleteButton();
  74. });
  75. }
  76. /**
  77. * Make a form builder.
  78. *
  79. * @return Form
  80. */
  81. protected function form()
  82. {
  83. return Form::make(new User(), function (Form $form) {
  84. $form->display('id');
  85. $form->text('name');
  86. // $form->text('open_id');
  87. $form->image('avatar')->disk('oss')->autoUpload()->saving(function ($res) {
  88. return $res;
  89. })->required();
  90. $form->text('mobile');
  91. // $form->text('status');
  92. // $form->text('online');
  93. // $form->text('last_login_ip');
  94. // $form->text('register_ip');
  95. // $form->text('last_login_time');
  96. $form->switch('is_black');
  97. // $form->text('sessionKey');
  98. $form->text('diamond');
  99. $form->switch('is_share');
  100. $form->text('share_name');
  101. $form->text('share_phone');
  102. // $form->text('share_pid');
  103. // $form->text('share_date');
  104. $form->text('income');
  105. // $form->text('qr_code');
  106. //
  107. // $form->display('created_at');
  108. // $form->display('updated_at');
  109. $form->disableDeleteButton();
  110. });
  111. }
  112. }