AccidentController.php 1.6 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->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 Accident(), function (Show $show) {
  37. $show->field('id');
  38. $show->field('student_id');
  39. $show->field('happen_time');
  40. $show->field('situation_detail');
  41. $show->field('creator_user_id');
  42. $show->field('created_at');
  43. $show->field('updated_at');
  44. });
  45. }
  46. /**
  47. * Make a form builder.
  48. *
  49. * @return Form
  50. */
  51. protected function form()
  52. {
  53. return Form::make(new Accident(), function (Form $form) {
  54. $form->text('student_id');
  55. $form->text('happen_time');
  56. $form->text('situation_detail');
  57. $form->text('creator_user_id');
  58. });
  59. }
  60. }