| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace App\Admin\Controllers;
- use App\Models\Attendance;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Layout\Content;
- //use Dcat\Admin\Http\Controllers\AdminController;
- use App\Admin\Controllers\AdminController;
- class AttendanceController extends AdminController
- {
- public function index($parent, Content $content)
- {
- $title = '考勤记录';
- return $content
- ->title($title)
- ->description('列表')
- // 添加面包屑导航
- ->breadcrumb([
- 'text' => '返回列表',
- 'url' => admin_url('/attendance'),
- 'icon' => 'fa fa-step-backward'
- ],['text' => $title]
- )
- ->body($this->grid($parent));
- }
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new Attendance(), function (Grid $grid) {
- $grid->column('id')->sortable();
- $grid->column('type');
- $grid->column('arrive_school_time');
- $grid->column('off_school_time');
- $grid->column('leave_type');
- $grid->column('leave_start_time');
- $grid->column('leave_end_time');
- $grid->column('created_at');
- $grid->column('updated_at')->sortable();
-
- $grid->filter(function (Grid\Filter $filter) {
- $filter->equal('id');
-
- });
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new Attendance(), function (Show $show) {
- $show->field('id');
- $show->field('type');
- $show->field('arrive_school_time');
- $show->field('off_school_time');
- $show->field('leave_type');
- $show->field('leave_start_time');
- $show->field('leave_end_time');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form($id)
- {
- return Form::make(new Attendance(), function (Form $form) use($id) {
- $form->row(function (Form\Row $row) {
- $row->width(6)->select('type')->options(config('map.sex'));
- $row->width(6)->datetime('arrive_school_time');
- });
- $form->row(function (Form\Row $row) {
- $row->width(6)->datetime('off_school_time');
- $row->width(6)->select('leave_type')->options(config('map.leave_type'));
-
- });
- $form->row(function (Form\Row $row) {
- $row->width(6)->datetime('leave_start_time');
- $row->width(6)->datetime('leave_end_time');
- });
- $form->disableListButton();
- $form->saved(function (Form $form) {
- return $form
- ->response()
- ->success('保存成功')
- ->redirect('/student');
- });
- });
- }
- }
|