<?php

namespace App\Admin\Controllers\OrdersManagement;

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

class UserSuggestsController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '病例意见单';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Suggest());
        $grid->disableCreateButton();
        $grid->disableActions();
        $uesr_id = \request('order_id');
        $grid->filter(function ($filter){
            $filter->disableIdFilter();
            $filter->equal('order_id','订单id');
        });
        $grid->column('id', __('Id'));
        $grid->column('order_id', __('订单id'));
        $grid->column('user_id', __('用户id'));
        $grid->column('patient_id', __('档案id'));
        $grid->column('symptoms', __('病症'))->limit(20,'...');
        $grid->column('pathogen', __('病因'))->limit(20,'...');
        $grid->column('suggest', __('结论建议'))->limit(20,'...');
        $grid->column('supplement_reason', __('补充原因'))->limit(20,'...');
        $grid->column('supplement_content', __('补充内容'))->limit(20,'...');
        $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(Suggest::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('order_id', __('Order id'));
        $show->field('user_id', __('User id'));
        $show->field('patient_id', __('Patient id'));
        $show->field('symptoms', __('Symptoms'));
        $show->field('pathogen', __('Pathogen'));
        $show->field('suggest', __('Suggest'));
        $show->field('supplement_reason', __('Supplement reason'));
        $show->field('supplement_content', __('Supplement content'));
        $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 Suggest());

        $form->number('order_id', __('Order id'));
        $form->number('user_id', __('User id'));
        $form->number('patient_id', __('Patient id'));
        $form->text('symptoms', __('Symptoms'));
        $form->text('pathogen', __('Pathogen'));
        $form->text('suggest', __('Suggest'));
        $form->text('supplement_reason', __('Supplement reason'));
        $form->text('supplement_content', __('Supplement content'));

        return $form;
    }
}
