<?php

namespace App\Admin\Controllers;

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

class TeachActivityController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new TeachActivity(), function (Grid $grid) {
            $grid->column('title');
            $grid->column('age');
            $grid->column('activity_type')->using(config('map.activity_type'));
            $grid->column('activity_time');
            $grid->column('creator_user_id')->using(config('map.teachers'));
            $grid->column('audit_status');
            $grid->disableViewButton();
            $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 TeachActivity(), function (Show $show) {
            $show->field('title');
            $show->field('age');
            $show->field('activity_type');
            $show->field('activity_time');
            $show->field('creator_user_id');
            $show->field('audit_status');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new TeachActivity(), function (Form $form) {
            $form->text('title');
            $form->text('age');
            $form->text('activity_type');
            $form->text('activity_time');
            $form->text('creator_user_id');
            $form->text('audit_status');

        });
    }
}
