<?php

namespace App\Admin\Controllers;

use App\Models\LeaveMessage;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class LeaveMessageController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new LeaveMessage(), function (Grid $grid) {
         
            $grid->column('parent_id')->using(config('map.parent_ids'));
            $grid->column('student_id')->using(config('map.students'));
            $grid->column('content')->limit(50);
            $grid->column('created_at');
            $grid->column('deal_status')->using(config('map.deal_status'));

            $grid->filter(function (Grid\Filter $filter) {
                $filter->panel();
                $filter->between('created_at')->datetime()->width(4);
                $filter->equal('student_id','输入/选择学生')->select(config('map.students'))->width(4);
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new LeaveMessage(), function (Show $show) {
            $show->field('id');
            $show->field('parent_id');
            $show->field('student_id');
            $show->field('content');
            $show->field('deal_status');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new LeaveMessage(), function (Form $form) {
          
            $form->text('parent_id');
            $form->text('student_id');
            $form->text('content');
            $form->text('deal_status');
        
        });
    }
}
