NoticeController.php 2.6 KB

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