78 lines
2.1 KiB
PHP
78 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\GoodsCategory;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Carbon\Carbon;
|
|
|
|
class GoodsCategoryController extends AdminController
|
|
{
|
|
|
|
protected $title = '商品分类';
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new GoodsCategory(), function (Grid $grid) {
|
|
$grid->column('id')->sortable();
|
|
$grid->column('category_name');
|
|
// $grid->column('category_icon')->image(100,100);
|
|
$grid->column('sort');
|
|
$grid->column('created_at');
|
|
$grid->column('updated_at')->sortable();
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
// $filter->equal('id');
|
|
$filter->equal('category_name');
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new GoodsCategory(), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('category_name');
|
|
// $show->field('category_icon');
|
|
$show->field('sort');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new GoodsCategory(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('category_name')->required();
|
|
// $form->image('category_icon')
|
|
// ->accept('jpg,png,gif,jpeg', 'image/*')
|
|
// ->move('milk-tea/goods_category/'.Carbon::now()->toDateString())
|
|
// ->saveFullUrl()->removable(false);
|
|
$form->number('sort')->default(0);
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
});
|
|
}
|
|
}
|