<?php

namespace App\Admin\Controllers;

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

class TeachPlanController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new TeachPlan(), function (Grid $grid) {
            $grid->column('title');
            $grid->column('time');
            $grid->column('plan_type')->using(config('map.plan_type'));
            $grid->column('create_user_id')->using(config('map.teachers'));
            $grid->column('content');
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new TeachPlan(), function (Show $show) {
            $show->field('title');
            $show->field('time');
            $show->field('plan_type');
            $show->field('create_user_id');
            $show->field('content');
            $show->field('photos');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new TeachPlan(), function (Form $form) {
            $form->text('title');
            $form->text('time');
            $form->text('plan_type');
            $form->text('create_user_id');
            $form->text('content');
            $form->text('photos');

        });
    }
}
