<?php

namespace App\Admin\Controllers\Market;

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

class RechargeComboController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new RechargeCombo(), function (Grid $grid) {
            $grid->model()->orderByDesc('status');
            $grid->column('id')->sortable();
            $grid->column('name');
            $grid->column('price');
            $grid->column('gold');
            $grid->column('gift');
            $grid->column('status')->switch();

            $grid->disableViewButton();
            $grid->disableRowSelector();
        });
    }

    /**
     * Make a show builder.
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new RechargeCombo(), function (Show $show) {
            $show->field('id');
            $show->field('name');
            $show->field('price');
            $show->field('gift');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new RechargeCombo(), function (Form $form) {
            $form->display('id');
            $form->text('name')->required();
            $form->text('price')->required();
            $form->text('gold')->required();
            $form->text('gift')->default(0);
            $form->switch('status')->default(1);

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