<?php

namespace App\Admin\Controllers;

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

class ShowroomCaseController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new ShowroomCase(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('showroom_id');
            $grid->column('name');
            $grid->column('videos');
            $grid->column('images');
            $grid->column('sort');
            $grid->column('is_opened');
            $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 ShowroomCase(), function (Show $show) {
            $show->field('id');
            $show->field('showroom_id');
            $show->field('name');
            $show->field('videos');
            $show->field('images');
            $show->field('sort');
            $show->field('is_opened');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new ShowroomCase(), function (Form $form) {
            $form->display('id');
            $form->text('showroom_id');
            $form->text('name');
            $form->text('videos');
            $form->text('images');
            $form->text('sort');
            $form->text('is_opened');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
