<?php

namespace App\Admin\Controllers\UserManagement\DocterManagement;

use App\Models\TeamDocter;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class DocterTeamController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '团队管理';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new TeamDocter());

        $docter_id = \request('docter_id');
        $grid->filter(function ($filter){
            $filter->disableIdFilter();
            $filter->equal('docter_id','医生');
        });
        //关闭操作栏
        $grid->disableActions();
        $grid->model()->orderBy('id','desc');
        $grid->column('id', __('Id'));
        $grid->column('docter_id', __('医生id'));
        $grid->column('docter.name', __('医生姓名'));
        $grid->column('team_id', __('团队id'));
        $grid->column('team.name', __('团队名称'));
        $grid->column('team.introduction', __('团队简介'));
        $grid->column('created_at', __('创建时间'));
        $grid->column('updated_at', __('更新时间'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(TeamDocter::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('docter_id', __('Docter id'));
        $show->field('team_id', __('Team id'));
        $show->field('created_at', __('Created at'));
        $show->field('updated_at', __('Updated at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new TeamDocter());

        $form->number('docter_id', __('Docter id'));
        $form->number('team_id', __('Team id'));

        return $form;
    }
}
