LeaveController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Leave;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class LeaveController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Leave(), function (Grid $grid) {
  18. $grid->column('student_id')->using(config('map.students'));
  19. $grid->column('leave_type')->using(config('map.leave_type'));
  20. $grid->column('reason');
  21. $grid->column('start_time');
  22. $grid->column('end_time');
  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 Leave(), function (Show $show) {
  38. $show->field('id');
  39. $show->field('student_id');
  40. $show->field('reason');
  41. $show->field('start_time');
  42. $show->field('end_time');
  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 Leave(), function (Form $form) {
  55. $form->display('id');
  56. $form->text('student_id');
  57. $form->text('reason');
  58. $form->text('start_time');
  59. $form->text('end_time');
  60. $form->display('created_at');
  61. $form->display('updated_at');
  62. });
  63. }
  64. }