<?php

namespace App\Admin\Controllers;

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

class CourseHoleController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new CourseHole(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('sort');
            $grid->column('course_id');
            $grid->column('par');
            $grid->column('difficulty');
            $grid->column('gold_dis');
            $grid->column('blue_dis');
            $grid->column('white_dis');
            $grid->column('red_dis');
            $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 CourseHole(), function (Show $show) {
            $show->field('id');
            $show->field('sort');
            $show->field('course_id');
            $show->field('par');
            $show->field('difficulty');
            $show->field('gold_dis');
            $show->field('blue_dis');
            $show->field('white_dis');
            $show->field('red_dis');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new CourseHole(), function (Form $form) {
            $form->display('id');
            $form->text('sort');
            $form->text('course_id');
            $form->text('par');
            $form->text('difficulty');
            $form->text('gold_dis');
            $form->text('blue_dis');
            $form->text('white_dis');
            $form->text('red_dis');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
