NoticeController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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->field('id');
  38. $show->field('teacher_id');
  39. $show->field('content');
  40. $show->field('created_at');
  41. $show->field('status');
  42. $show->field('updated_at');
  43. });
  44. }
  45. /**
  46. * Make a form builder.
  47. *
  48. * @return Form
  49. */
  50. protected function form()
  51. {
  52. return Form::make(new Notice(), function (Form $form) {
  53. $form->text('teacher_id');
  54. $form->text('content');
  55. $form->text('status');
  56. $form->text('title');
  57. $form->text('desc');
  58. $form->text('photos');
  59. $form->text('pdf_file');
  60. });
  61. }
  62. }