<?php

namespace App\Admin\Controllers\Program;

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

class HomeColumnController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new HomeColumn(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('name')->editable();
            $grid->column('sort')->editable()->sortable();
            $grid->column('status')->switch('', true);

            $grid->disableCreateButton();
            $grid->disableBatchDelete();
            $grid->disableDeleteButton();
            $grid->disableViewButton();
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new HomeColumn(), function (Form $form) {
            $form->display('id');
            $form->text('name');
            //            $form->image('icon')->uniqueName()->autoUpload()
            //                ->autoSave(false)
            //                ->removable(false)
            //                ->width(4);
            $form->number('sort');
            $form->switch('status');

            $form->disableDeleteButton();
            $form->disableViewButton();
            $form->disableViewCheck();
            $form->disableEditingCheck();
            $form->disableCreatingCheck();
        });
    }
}
