<?php

namespace App\Admin\Controllers;

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

class UserWalletController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new UserWallet(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('user_address');
            $grid->column('buy_list');
            $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 UserWallet(), function (Show $show) {
            $show->field('id');
            $show->field('user_address');
            $show->field('buy_list');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new UserWallet(), function (Form $form) {
            $form->display('id');
            $form->text('user_address');
            $form->text('buy_list');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
