NoticeController.php 2.6 KB

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