<?php

namespace App\Admin\Controllers\Resume;

use App\Models\ResumeGroup;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;

class GroupController extends AdminController
{

    protected $title = '科室管理';

    public function grid()
    {
        $grid = new Grid(new ResumeGroup());
        $grid->model()->orderBy('id', 'desc');

        $grid->filter(function ($filter) {
            $filter->column(1 / 2, function ($filter) {
                $filter->like('name', '名称');
            });
            $filter->disableIdFilter();
        });

        $grid->column('id', '#ID#');
        $grid->column('name', '名称');
        $grid->column('status', '状态')->switch();
        $grid->column('created_at', '创建时间');
        return $grid;
    }

    public function form(): Form
    {
        $form = new Form(new ResumeGroup);

        $form->text('name', '名称')->rules('min:2')->required();
        $form->switch('status', '状态')->default(1);
        return $form;
    }

}
