<?php

namespace App\Admin\Controllers;

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

class VipController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new VipModel(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('title');
            $grid->column('price');
            $grid->column('day');
            $grid->column('day_price');
            $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 VipModel(), function (Show $show) {
            $show->field('id');
            $show->field('title');
            $show->field('price');
            $show->field('day');
            $show->field('day_price');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new VipModel(), function (Form $form) {
            $form->display('id');
            $form->text('title');
            $form->text('price');
            $form->text('day');
            $form->text('day_price');
        });
    }
}
