<?php

namespace App\Admin\Controllers\Program;

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

class TabbarController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Tabbar(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('name')->editable();
            $grid->column('icon')->image('', 50);
            $grid->column('selected_icon')->image('', 50);
            //            $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 Tabbar(), function (Form $form) {
            $form->display('id');
            $form->text('name')->required();
            $form->image('icon')->saveFullUrl()->uniqueName()->autoUpload()
                ->autoSave(false)
                ->removable(false)
                ->width(4)->required();

            $form->image('selected_icon')->saveFullUrl()->uniqueName()->autoUpload()
            ->autoSave(false)
            ->removable(false)
            ->width(4)->required();
            //            $form->number('sort');
            $form->switch('status', true);

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