<?php

namespace App\Admin\Controllers;

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

class StudentController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Student(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('name');
            $grid->column('sex');
            $grid->column('month_old');
            $grid->column('join_garden_time');
            $grid->column('parent_name');
            $grid->column('class_id');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
                $filter->panel();
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new Student(), function (Show $show) {
            $show->field('id');
            $show->field('name');
            $show->field('sex');
            $show->field('month_old');
            $show->field('join_garden_time');
            $show->field('parent_name');
            $show->field('class_id');
            $show->field('name_en');
            $show->field('blood_type');
            $show->field('hypersensitive_source');
            $show->field('past_medical_history');
            $show->field('birthday');
            $show->field('exclusive_consultant_name');
            $show->field('exclusive_consultant_phone');
            $show->field('home_address');
            $show->field('hobby');
            $show->field('family_lang');
            $show->field('sleep_habits_and_others');
            $show->field('first_communication_of_parents');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Student(), function (Form $form) {
            $form->display('id');
            $form->text('name');
            $form->text('sex');
            $form->text('month_old');
            $form->text('join_garden_time');
            $form->text('parent_name');
            $form->text('class_id');
            $form->text('name_en');
            $form->text('blood_type');
            $form->text('hypersensitive_source');
            $form->text('past_medical_history');
            $form->text('birthday');
            $form->text('exclusive_consultant_name');
            $form->text('exclusive_consultant_phone');
            $form->text('home_address');
            $form->text('hobby');
            $form->text('family_lang');
            $form->text('sleep_habits_and_others');
            $form->text('first_communication_of_parents');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
