AttendanceController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Attendance;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Layout\Content;
  8. //use Dcat\Admin\Http\Controllers\AdminController;
  9. use App\Admin\Controllers\AdminController;
  10. class AttendanceController extends AdminController
  11. {
  12. public function index($parent, Content $content)
  13. {
  14. $title = '考勤记录';
  15. return $content
  16. ->title($title)
  17. ->description('列表')
  18. // 添加面包屑导航
  19. ->breadcrumb([
  20. 'text' => '返回列表',
  21. 'url' => admin_url('/attendance'),
  22. 'icon' => 'fa fa-step-backward'
  23. ],['text' => $title]
  24. )
  25. ->body($this->grid($parent));
  26. }
  27. /**
  28. * Make a grid builder.
  29. *
  30. * @return Grid
  31. */
  32. protected function grid()
  33. {
  34. return Grid::make(new Attendance(), function (Grid $grid) {
  35. $grid->column('id')->sortable();
  36. $grid->column('type');
  37. $grid->column('arrive_school_time');
  38. $grid->column('off_school_time');
  39. $grid->column('leave_type');
  40. $grid->column('leave_start_time');
  41. $grid->column('leave_end_time');
  42. $grid->column('created_at');
  43. $grid->column('updated_at')->sortable();
  44. $grid->filter(function (Grid\Filter $filter) {
  45. $filter->equal('id');
  46. });
  47. });
  48. }
  49. /**
  50. * Make a show builder.
  51. *
  52. * @param mixed $id
  53. *
  54. * @return Show
  55. */
  56. protected function detail($id)
  57. {
  58. return Show::make($id, new Attendance(), function (Show $show) {
  59. $show->field('id');
  60. $show->field('type');
  61. $show->field('arrive_school_time');
  62. $show->field('off_school_time');
  63. $show->field('leave_type');
  64. $show->field('leave_start_time');
  65. $show->field('leave_end_time');
  66. $show->field('created_at');
  67. $show->field('updated_at');
  68. });
  69. }
  70. /**
  71. * Make a form builder.
  72. *
  73. * @return Form
  74. */
  75. protected function form($id)
  76. {
  77. return Form::make(new Attendance(), function (Form $form) use($id) {
  78. $form->row(function (Form\Row $row) {
  79. $row->width(6)->select('type')->options(config('map.sex'));
  80. $row->width(6)->datetime('arrive_school_time');
  81. });
  82. $form->row(function (Form\Row $row) {
  83. $row->width(6)->datetime('off_school_time');
  84. $row->width(6)->select('leave_type')->options(config('map.leave_type'));
  85. });
  86. $form->row(function (Form\Row $row) {
  87. $row->width(6)->datetime('leave_start_time');
  88. $row->width(6)->datetime('leave_end_time');
  89. });
  90. $form->disableListButton();
  91. $form->saved(function (Form $form) {
  92. return $form
  93. ->response()
  94. ->success('保存成功')
  95. ->redirect('/student');
  96. });
  97. });
  98. }
  99. }