WxUserReportController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace App\Admin\Controllers\User;
  3. use App\Admin\Repositories\User\WxUserReport;
  4. use App\Wen\Utils\FieldUtils;
  5. use App\Wen\Utils\Utils;
  6. use Dcat\Admin\Form;
  7. use Dcat\Admin\Grid;
  8. use Dcat\Admin\Show;
  9. use Dcat\Admin\Http\Controllers\AdminController;
  10. class WxUserReportController extends AdminController
  11. {
  12. /**
  13. * Make a grid builder.
  14. *
  15. * @return Grid
  16. */
  17. protected function grid()
  18. {
  19. return Grid::make(new WxUserReport(), function (Grid $grid) {
  20. $grid->simplePaginate();
  21. $grid->quickSearch(['id', 'user_id', 'object_id'])->placeholder('搜索id,用户id...')->width(35);
  22. $grid->model()->orderBy('id', 'desc');
  23. $grid->column('id')->sortable();
  24. $grid->column('type')->using([0=>'笔记', 1=> '评论', 2 => '用户', 3=> '商品']);
  25. $grid->column('user_id')->display(function ($v){
  26. return '<a href="'.admin_url('users?id='.$v).'" target="_blank"> '.$v.'</a>';
  27. });
  28. $grid->column('object_id');
  29. $grid->column('report_type')->using(FieldUtils::getReportTypes());
  30. $grid->column('report_message');
  31. $grid->column('report_imgs')->display(function ($v) {
  32. if(_empty_($v)){
  33. return '';
  34. }
  35. $imgs = explode(',', $v);
  36. $html = '<div style="max-width: 350px; overflow-x: scroll;">';
  37. foreach ($imgs as $img){
  38. $html .= '<img data-action="preview-img" style="max-width: 50px;margin-right: 10px;" src="'.Utils::imgWithStyle($img).'" / >';
  39. }
  40. return $html.'</div>';
  41. })->width('50px');
  42. $grid->column('contact');
  43. // $grid->column('created_at');
  44. $grid->column('updated_at')->sortable();
  45. $grid->filter(function (Grid\Filter $filter) {
  46. $filter->equal('id');
  47. });
  48. $grid->disableViewButton();
  49. $grid->disableCreateButton();
  50. $grid->disableActions();
  51. $grid->disableBatchActions();
  52. });
  53. }
  54. /**
  55. * Make a show builder.
  56. *
  57. * @param mixed $id
  58. *
  59. * @return Show
  60. */
  61. protected function detail($id)
  62. {
  63. return Show::make($id, new WxUserReport(), function (Show $show) {
  64. $show->field('id');
  65. $show->field('type');
  66. $show->field('user_id');
  67. $show->field('object_id');
  68. $show->field('report_type');
  69. $show->field('report_message');
  70. $show->field('created_at');
  71. $show->field('updated_at');
  72. });
  73. }
  74. /**
  75. * Make a form builder.
  76. *
  77. * @return Form
  78. */
  79. protected function form()
  80. {
  81. return Form::make(new WxUserReport(), function (Form $form) {
  82. $form->display('id');
  83. $form->text('type');
  84. $form->text('user_id');
  85. $form->text('object_id');
  86. $form->text('report_type');
  87. $form->text('report_message');
  88. $form->display('created_at');
  89. $form->display('updated_at');
  90. $form->deleting(function (Form $form){
  91. global $__MINI_GLOBAL_TENANT_ID__;
  92. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  93. return $form->response()->error('权限不足,不可以删除其他分站对象');
  94. }
  95. });
  96. });
  97. }
  98. }