ShareUserController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. * @param mixed $id
  45. *
  46. * @return Show
  47. */
  48. protected function detail($id)
  49. {
  50. return Show::make($id, new User(), function (Show $show) {
  51. $show->model()->with('userShare');
  52. $show->field('id');
  53. $show->field('name');
  54. $show->field('open_id','微信openid');
  55. $show->field('avatar')->image();
  56. $show->field('mobile');
  57. $show->field('online');
  58. $show->field('last_login_ip');
  59. $show->field('last_login_time');
  60. $show->field('is_black')->as(function ($item){
  61. return $item ? '拉黑' : '正常';
  62. });
  63. $show->field('diamond');
  64. $show->field('is_share')->as(function ($item){
  65. return $item ? '是推广人' : '不是推广人';
  66. });
  67. $show->field('share_name');
  68. $show->field('share_phone');
  69. $show->field('userShare.name','推广人昵称(被)');
  70. $show->field('share_date');
  71. $show->field('income');
  72. $show->field('qr_code')->image();
  73. $show->field('created_at');
  74. $show->field('updated_at');
  75. $show->disableDeleteButton();
  76. });
  77. }
  78. /**
  79. * Make a form builder.
  80. *
  81. * @return Form
  82. */
  83. protected function form()
  84. {
  85. return Form::make(new User(), function (Form $form) {
  86. $form->display('id');
  87. $form->text('name');
  88. // $form->text('open_id');
  89. $form->image('avatar')->disk('oss')->autoUpload()->saving(function ($res) {
  90. return $res;
  91. })->required();;
  92. $form->text('mobile');
  93. // $form->text('status');
  94. // $form->text('online');
  95. // $form->text('last_login_ip');
  96. // $form->text('register_ip');
  97. // $form->text('last_login_time');
  98. $form->switch('is_black');
  99. // $form->text('sessionKey');
  100. $form->text('diamond');
  101. $form->switch('is_share');
  102. $form->text('share_name');
  103. $form->text('share_phone');
  104. // $form->text('share_pid');
  105. // $form->text('share_date');
  106. $form->text('income');
  107. // $form->text('qr_code');
  108. //
  109. // $form->display('created_at');
  110. // $form->display('updated_at');
  111. $form->disableDeleteButton();
  112. });
  113. }
  114. }