<?php

namespace App\Admin\Controllers;

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

class MemberAddressController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new MemberAddress(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('user_id');
            $grid->column('user_name');
            $grid->column('mobile');
            $grid->column('sex');
            $grid->column('province');
            $grid->column('city');
            $grid->column('district');
            $grid->column('address');
            $grid->column('address_info');
            $grid->column('city_code');
            $grid->column('lng');
            $grid->column('lat');
            $grid->column('status');
            $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 MemberAddress(), function (Show $show) {
            $show->field('id');
            $show->field('user_id');
            $show->field('user_name');
            $show->field('mobile');
            $show->field('sex');
            $show->field('province');
            $show->field('city');
            $show->field('district');
            $show->field('address');
            $show->field('address_info');
            $show->field('city_code');
            $show->field('lng');
            $show->field('lat');
            $show->field('status');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new MemberAddress(), function (Form $form) {
            $form->display('id');
            $form->text('user_id');
            $form->text('user_name');
            $form->text('mobile');
            $form->text('sex');
            $form->text('province');
            $form->text('city');
            $form->text('district');
            $form->text('address');
            $form->text('address_info');
            $form->text('city_code');
            $form->text('lng');
            $form->text('lat');
            $form->text('status');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
