<?php

namespace App\Admin\Controllers;

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

class TeamDocterController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '团队——医生表';

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

        $grid->filter(function ($filter){
            $filter->disableIdFilter();
            $filter->equal('team_id','团队');
        });
        $grid->column('id', __('Id'));
        $grid->column('docter_id', __('医生ID'));
        $grid->column('docter.name', __('医生姓名'));
        $grid->column('team.name', __('团队名称'));
        $grid->column('team.introduction', __('团队简介'));
        $grid->column('created_at', __('创建时间'));
        $grid->column('updated_at', __('更新时间'));

        return $grid;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new TeamDocter());
        $form->select('docter_id', __('医生名称'))->options(function (){
            return Docter::where('is_then', 1)->pluck('name', 'id');
        });
//        $form->saving(function (Form $form){
//           $form -> team_id = $form ->
//        });
        $form->text('team_id', __('团队ID'));

        return $form;
    }
}
