WxUsedCommentController.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. namespace App\Admin\Controllers\Used;
  3. use App\Admin\Actions\Grid\UsedCommentsPassAction;
  4. use App\Admin\Repositories\Used\WxUsedComment;
  5. use App\Wen\Utils\Settings;
  6. use Dcat\Admin\Form;
  7. use Dcat\Admin\Grid;
  8. use Dcat\Admin\Show;
  9. use Dcat\Admin\Http\Controllers\AdminController;
  10. class WxUsedCommentController extends AdminController
  11. {
  12. /**
  13. * Make a grid builder.
  14. *
  15. * @return Grid
  16. */
  17. protected function grid()
  18. {
  19. return Grid::make(new WxUsedComment(), function (Grid $grid) {
  20. $grid->model()->orderBy('id', 'desc');
  21. $grid->column('id')->sortable();
  22. $grid->quickSearch(['id', 'comment_content'])->placeholder('搜索ID,评论内容...')->width(50);
  23. $grid->column('owers', '头像')->display(function ($v) {
  24. return '<img src="' . ($this->ower['user_avatar'] ?? Settings::get('img_default', 'https://img.mini.minisns.cn/icons/dafault.png')) . '" style="border-radius:50px;width:30px;" />';
  25. })->width('50px');
  26. $grid->column('ower', '用户名称')->display(function ($v) {
  27. if($v && $v['user_name']){
  28. return '<a target="_blank" href="'.admin_url('users?id='.$v['id']).'">'.$v['user_name'].'</a>' ?? '用户已删除';
  29. }
  30. return '用户已删除';
  31. })->width('100px');
  32. $grid->column('used_good_id');
  33. $grid->column('comment_id');
  34. $grid->column('comment_agent_id');
  35. $grid->column('comment_agent_name');
  36. $grid->column('comment_content')->limit(40);
  37. $grid->column('comment_img_url')->image('', 60, 60);
  38. // $grid->column('longitude');
  39. // $grid->column('latitude');
  40. // $grid->column('ip');
  41. // $grid->column('country');
  42. // $grid->column('province');
  43. // $grid->column('city');
  44. // $grid->column('district');
  45. $grid->column('comment_state', '状态')->using([0 => '待审核', 1 => '审核通过', 2 => '驳回'])->label([
  46. 0 => 'red',
  47. 1 => 'green',
  48. 2 => 'default'
  49. ]);
  50. // $grid->column('created_at');
  51. $grid->column('updated_at')->sortable();
  52. $grid->filter(function (Grid\Filter $filter) {
  53. $filter->equal('id');
  54. });
  55. $grid->batchActions(function ($batch) {
  56. $batch->add(new UsedCommentsPassAction());
  57. });
  58. $grid->disableCreateButton();
  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 WxUsedComment(), function (Show $show) {
  71. $show->field('id');
  72. $show->field('user_id');
  73. $show->field('used_good_id');
  74. $show->field('comment_id');
  75. $show->field('comment_agent_id');
  76. $show->field('comment_agent_name');
  77. $show->field('comment_content');
  78. $show->field('comment_img_url');
  79. $show->field('longitude');
  80. $show->field('latitude');
  81. $show->field('ip');
  82. $show->field('country');
  83. $show->field('province');
  84. $show->field('city');
  85. $show->field('district');
  86. $show->field('comment_state');
  87. $show->field('created_at');
  88. $show->field('updated_at');
  89. });
  90. }
  91. /**
  92. * Make a form builder.
  93. *
  94. * @return Form
  95. */
  96. protected function form()
  97. {
  98. return Form::make(new WxUsedComment(), function (Form $form) {
  99. $form->display('id');
  100. $form->text('user_id');
  101. $form->text('used_good_id');
  102. $form->text('comment_id');
  103. $form->text('comment_agent_id');
  104. $form->text('comment_agent_name');
  105. $form->text('comment_content');
  106. $form->text('comment_img_url');
  107. $form->text('longitude');
  108. $form->text('latitude');
  109. $form->text('ip');
  110. $form->text('country');
  111. $form->text('province');
  112. $form->text('city');
  113. $form->text('district');
  114. $form->text('comment_state');
  115. $form->display('created_at');
  116. $form->display('updated_at');
  117. $form->deleting(function (Form $form){
  118. global $__MINI_GLOBAL_TENANT_ID__;
  119. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  120. return $form->response()->error('权限不足,不可以删除其他分站对象');
  121. }
  122. });
  123. });
  124. }
  125. }