WxPetsCommentController.php 4.5 KB

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