<?php

namespace App\Admin\Controllers;

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

class AiCountController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Config(), function (Grid $grid) {
            $grid->model()->whereIn('id',[18]);
            $grid->column('id')->sortable();
            $grid->column('desc','标题');

            $grid->column('value', '值')->display(function ($item) use ($grid) {});
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
            $grid->disableDeleteButton();
            $grid->disableCreateButton();
            $grid->disableViewButton();
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new Config(), function (Show $show) {
            $show->field('id');
            $show->field('key');
            $show->field('value');
            $show->field('desc');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Config(), function (Form $form) {
            $form->display('id');
            $form->table('value', function (NestedForm $table) {
                $table->select('lv','请选择年纪')->options([0 => '幼儿园',1 => '一年级',2 => '二年级',3 => '三年级',4 => '四年级',5 => '五年级',6 => '六年级',]);
                $table->number('count','字数');
            });
            $form->display('desc','标题');
            $form->disableViewButton();
            $form->disableDeleteButton();
        });
    }
}
