<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\MemberConfig;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class MemberConfigController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new MemberConfig(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('point_trade_deduct_enable');
            $grid->column('point_trade_deduct_unit_price');
            $grid->column('point_trade_deduct_max_price');
            $grid->column('point_trade_give_point');
            $grid->column('creator');
            $grid->column('updater');
            $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 MemberConfig(), function (Show $show) {
            $show->field('id');
            $show->field('point_trade_deduct_enable');
            $show->field('point_trade_deduct_unit_price');
            $show->field('point_trade_deduct_max_price');
            $show->field('point_trade_give_point');
            $show->field('creator');
            $show->field('updater');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new MemberConfig(), function (Form $form) {
            $form->display('id');
            $form->text('point_trade_deduct_enable');
            $form->text('point_trade_deduct_unit_price');
            $form->text('point_trade_deduct_max_price');
            $form->text('point_trade_give_point');
            $form->text('creator');
            $form->text('updater');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
