海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

82 lines
1.9 KiB

<?php
namespace App\Admin\Controllers;
use App\Common\UserStatus;
use App\Models\Category;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Tree;
class CategoryController extends AdminController
{
public function index(Content $content)
{
return $content->header('产品分类')
->body(function (Row $row) {
$tree = new Tree(new Category);
$tree->expand();
$tree->query(function ($model) {
//agent_id为0是系统分类,其它是代理商分类
return $model->where('agent_id', 0);
});
$row->column(12, $tree);
});
}
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Category(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('pid');
$grid->column('name');
$grid->column('sort');
$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 Category(), function (Show $show) {
$show->field('id');
$show->field('pid');
$show->field('name');
$show->field('sort');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new Category(), function (Form $form) {
$form->display('id');
$form->select('pid')->options(Category::selectOptions());
$form->text('name');
$form->text('sort')->default(255);
});
}
}