NoticeController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace App\Community\Controllers;
  3. use App\Models\CommunityNotice;
  4. use App\Models\Notice;
  5. use App\Models\User;
  6. use Encore\Admin\Controllers\AdminController;
  7. use Encore\Admin\Facades\Admin;
  8. use Encore\Admin\Form;
  9. use Encore\Admin\Grid;
  10. use Encore\Admin\Layout\Content;
  11. use Encore\Admin\Show;
  12. class NoticeController extends AdminController
  13. {
  14. /**
  15. * Title for current resource.
  16. *
  17. * @var string
  18. */
  19. protected $title = '通告列表';
  20. /**
  21. * Make a grid builder.
  22. *
  23. * @return Grid
  24. */
  25. protected function grid()
  26. {
  27. $content = new Content();
  28. $content->title('通知公告')
  29. ->description('公告列表');
  30. $user = Admin::user();
  31. $org_id = $user->org_id;
  32. $docter_id = $user->docter_id;
  33. $notice = CommunityNotice::get();
  34. if($org_id){
  35. $notice = CommunityNotice::where('organization_id',$org_id)->get();
  36. }
  37. $content->view('cdms.notice',['notice'=>$notice]);
  38. return $content;
  39. }
  40. /**
  41. * Make a show builder.
  42. *
  43. * @param mixed $id
  44. * @return Show
  45. */
  46. protected function detail($id)
  47. {
  48. $show = new Show(Notice::findOrFail($id));
  49. $show->field('id', __('Id'));
  50. $show->field('org_id', __('Org id'));
  51. $show->field('title', __('Title'));
  52. $show->field('content', __('Content'));
  53. $show->field('remark', __('Remark'));
  54. $show->field('created_at', __('Created at'));
  55. $show->field('updated_at', __('Updated at'));
  56. return $show;
  57. }
  58. /**
  59. * Make a form builder.
  60. *
  61. * @return Form
  62. */
  63. protected function form()
  64. {
  65. $form = new Form(new Notice());
  66. $form->number('org_id', __('Org id'));
  67. $form->text('title', __('Title'));
  68. $form->text('content', __('Content'));
  69. $form->text('remark', __('Remark'));
  70. return $form;
  71. }
  72. public function send(Content $content)
  73. {
  74. $content->title('fasong');
  75. $content->header('群发邮件');
  76. $form = new \Encore\Admin\Widgets\Form();
  77. $form->action('send');
  78. $form->method('post');
  79. $user = User::distinct()->pluck('nickname','id');
  80. $form->multipleSelect('user_ids','用户')->options($user);
  81. $form->text('title','标题')->rules('required',['requried'=>'请输入标题'])->placeholder('请输入标题,最多50个字');
  82. $form->textarea('content','内容')->rules('required')->placeholder('请输入标题,最多200个字');
  83. $form->textarea('remark','备注')->placeholder('请输入标题,最多200个字');;
  84. $content->row($form);
  85. $dibu = '<div>这是底部</div>';
  86. $content->row($dibu);
  87. return $content;
  88. }
  89. }