<?php

namespace App\Admin\Controllers;

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

class OrderItemController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new OrderItem(), function (Grid $grid) {
            $grid->column('rec_id')->sortable();
            $grid->column('order_id');
            $grid->column('user_id');
            $grid->column('goods_id');
            $grid->column('supplier_id');
            $grid->column('brand_id');
            $grid->column('standard_brand_id');
            $grid->column('goods_name');
            $grid->column('supplier_name');
            $grid->column('brand_name');
            $grid->column('standard_brand_name');
            $grid->column('goods_type');
            $grid->column('goods_number');
            $grid->column('goods_price');
            $grid->column('delivery_time');
            $grid->column('canal');
            $grid->column('status');
            $grid->column('initial_price');
            $grid->column('purchase_uid');
            $grid->column('contract_remark');
            $grid->column('tax_rate');
        
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('rec_id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new OrderItem(), function (Show $show) {
            $show->field('rec_id');
            $show->field('order_id');
            $show->field('user_id');
            $show->field('goods_id');
            $show->field('supplier_id');
            $show->field('brand_id');
            $show->field('standard_brand_id');
            $show->field('goods_name');
            $show->field('supplier_name');
            $show->field('brand_name');
            $show->field('standard_brand_name');
            $show->field('goods_type');
            $show->field('goods_number');
            $show->field('goods_price');
            $show->field('delivery_time');
            $show->field('canal');
            $show->field('status');
            $show->field('initial_price');
            $show->field('purchase_uid');
            $show->field('contract_remark');
            $show->field('tax_rate');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new OrderItem(), function (Form $form) {
            $form->display('rec_id');
            $form->text('order_id');
            $form->text('user_id');
            $form->text('goods_id');
            $form->text('supplier_id');
            $form->text('brand_id');
            $form->text('standard_brand_id');
            $form->text('goods_name');
            $form->text('supplier_name');
            $form->text('brand_name');
            $form->text('standard_brand_name');
            $form->text('goods_type');
            $form->text('goods_number');
            $form->text('goods_price');
            $form->text('delivery_time');
            $form->text('canal');
            $form->text('status');
            $form->text('initial_price');
            $form->text('purchase_uid');
            $form->text('contract_remark');
            $form->text('tax_rate');
        });
    }
}