<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\DistAppearanceVariable;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Admin;

class DistAppearanceVariableController extends AdminController
{
    /**
     * page index
     */
    public function index(Content $content)
    {
        return $content
            ->header('列表')
            ->description('全部')
            ->breadcrumb(['text'=>'列表','url'=>''])
            ->body($this->grid());
    }

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new DistAppearanceVariable(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('dist_id');
            $grid->column('appearance_id');
            $grid->column('variable_name');
            $grid->column('variable_value');
            $grid->column('variable_type');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
        
            $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 DistAppearanceVariable(), function (Show $show) {
            $show->field('id');
            $show->field('dist_id');
            $show->field('appearance_id');
            $show->field('variable_name');
            $show->field('variable_value');
            $show->field('variable_type');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new DistAppearanceVariable(), function (Form $form) {
            $form->display('id');
            $form->text('dist_id');
            $form->text('appearance_id');
            $form->text('variable_name');
            $form->text('variable_value');
            $form->text('variable_type');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
