WxNoticeController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\WxNotice;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxNoticeController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxNotice('user'), function (Grid $grid) {
  18. $grid->simplePaginate();
  19. $grid->model()->orderBy('id','desc');
  20. // $grid->column('id')->sortable();
  21. $grid->column('user.user_avatar', '用户头像')->image('', 50);
  22. $grid->column('user.user_name', '用户名');
  23. $grid->column('title');
  24. $grid->column('content')->limit(8);
  25. $grid->column('is_read')->using([0 => '用户未读', 1 => '用户已读'])->label([
  26. 0 => 'red',
  27. 1 => 'primary',
  28. ]);
  29. $grid->column('notice_type')->using([0 => '系统通知', 1 => '活动通知', 2 => '点赞通知', 3 => '收藏通知', 4 => '评论通知', 5 => '评论点赞通知', 8 => '发货通知'])->label([
  30. 0 => 'blue',
  31. 1 => 'primary',
  32. 2 => 'red',
  33. 3 => 'green',
  34. 4 => 'orange2',
  35. 5 => 'pink',
  36. 8 => 'primary',
  37. ]);
  38. $grid->column('created_at');
  39. $grid->column('updated_at')->sortable();
  40. $grid->filter(function (Grid\Filter $filter) {
  41. $filter->equal('id');
  42. });
  43. $grid->disableCreateButton();
  44. $grid->disableActions();
  45. $grid->disableBatchDelete();
  46. });
  47. }
  48. /**
  49. * Make a show builder.
  50. *
  51. * @param mixed $id
  52. *
  53. * @return Show
  54. */
  55. protected function detail($id)
  56. {
  57. return Show::make($id, new WxNotice(), function (Show $show) {
  58. $show->field('id');
  59. $show->field('user_id');
  60. $show->field('posts_id');
  61. $show->field('title');
  62. $show->field('content');
  63. $show->field('is_read');
  64. $show->field('notice_type');
  65. $show->field('created_at');
  66. $show->field('updated_at');
  67. });
  68. }
  69. /**
  70. * Make a form builder.
  71. *
  72. * @return Form
  73. */
  74. protected function form()
  75. {
  76. return Form::make(new WxNotice(), function (Form $form) {
  77. $form->display('id');
  78. $form->text('user_id');
  79. $form->text('posts_id');
  80. $form->text('title');
  81. $form->text('content');
  82. $form->text('is_read');
  83. $form->text('notice_type');
  84. $form->deleting(function (Form $form){
  85. global $__MINI_GLOBAL_TENANT_ID__;
  86. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  87. return $form->response()->error('权限不足,不可以删除其他分站对象');
  88. }
  89. });
  90. });
  91. }
  92. }