NoticeController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Notice;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class NoticeController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Notice(), function (Grid $grid) {
  18. $grid->column('teacher_id')->using(config('map.teachers'));
  19. $grid->column('content');
  20. $grid->column('created_at');
  21. $grid->column('status')->using(config('map.notice_status'));
  22. $grid->filter(function (Grid\Filter $filter) {
  23. $filter->equal('id');
  24. });
  25. });
  26. }
  27. /**
  28. * Make a show builder.
  29. *
  30. * @param mixed $id
  31. *
  32. * @return Show
  33. */
  34. protected function detail($id)
  35. {
  36. return Show::make($id, new Notice(), function (Show $show) {
  37. $show->row(function (Show\Row $show) {
  38. $show->width(12)->field('content');
  39. $show->width(12)->field('teacher_id','通知对象')->using(config('map.teachers'));
  40. });
  41. // $show->field('teacher_id');
  42. // $show->field('content');
  43. // $show->field('created_at');
  44. // $show->field('status');d
  45. // $show->field('updated_at');
  46. });
  47. }
  48. /**
  49. * Make a form builder.
  50. *
  51. * @return Form
  52. */
  53. protected function form()
  54. {
  55. return Form::make(new Notice(), function (Form $form) {
  56. $form->row(function (Form\Row $form) {
  57. $form->width(12)->text('title');
  58. $form->width(12)->textarea('content');
  59. $form->multipleImage('photos','上传照片')->saveAsJson();
  60. $form->file('pdf_file','点击上传文件')->help('上传格式为PDF,且大小不超过100MB');
  61. });
  62. //$form->disableViewButton();
  63. // $form->text('teacher_id');
  64. // $form->text('status');
  65. // $form->text('desc');
  66. });
  67. }
  68. }