AccidentController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Accident;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class AccidentController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Accident(), function (Grid $grid) {
  18. $grid->column('student_id')->using(config('map.students'));
  19. $grid->column('happen_time');
  20. $grid->column('situation_detail');
  21. $grid->column('creator_user_id')->using(config('map.teachers'));
  22. $grid->disableActions();
  23. $grid->filter(function (Grid\Filter $filter) {
  24. $filter->equal('id');
  25. });
  26. });
  27. }
  28. /**
  29. * Make a show builder.
  30. *
  31. * @param mixed $id
  32. *
  33. * @return Show
  34. */
  35. protected function detail($id)
  36. {
  37. return Show::make($id, new Accident(), function (Show $show) {
  38. $show->field('id');
  39. $show->field('student_id');
  40. $show->field('happen_time');
  41. $show->field('situation_detail');
  42. $show->field('creator_user_id');
  43. $show->field('created_at');
  44. $show->field('updated_at');
  45. });
  46. }
  47. /**
  48. * Make a form builder.
  49. *
  50. * @return Form
  51. */
  52. protected function form()
  53. {
  54. return Form::make(new Accident(), function (Form $form) {
  55. $form->text('student_id');
  56. $form->text('happen_time');
  57. $form->text('situation_detail');
  58. $form->text('creator_user_id');
  59. });
  60. }
  61. }