6
0
Fork 0

调整后台分类以及列表

release
vine_liutk 2022-01-18 11:39:35 +08:00 committed by 李静
parent 16b4398af9
commit 162d4fbd46
3 changed files with 11 additions and 3 deletions

View File

@ -24,10 +24,12 @@ class ProductCategoryController extends AdminController
*/ */
protected function grid() protected function grid()
{ {
return Grid::make(new ProductCategory(), function (Grid $grid) { $builder = ProductCategory::with('parent');
return Grid::make($builder, function (Grid $grid) {
$grid->column('id')->sortable(); $grid->column('id')->sortable();
$grid->column('name')->tree(); $grid->column('name');
$grid->column('icon')->image(50, 50); $grid->column('icon')->image(50, 50);
$grid->column('parent.name', '上级分类')->label();
$grid->column('is_show') $grid->column('is_show')
->if(function () { ->if(function () {
return Admin::user()->can('dcat.admin.product_categories.edit'); return Admin::user()->can('dcat.admin.product_categories.edit');
@ -71,6 +73,7 @@ class ProductCategoryController extends AdminController
$grid->filter(function (Grid\Filter $filter) { $grid->filter(function (Grid\Filter $filter) {
$filter->panel(); $filter->panel();
$filter->equal('name')->width(3); $filter->equal('name')->width(3);
$filter->equal('parent_id', '上级分类')->select(ProductCategoryModel::selectOptions())->width(3);
}); });
}); });
} }

View File

@ -26,7 +26,7 @@ class PartController extends Controller
$part = ProductPart::where('key', $key)->first(); $part = ProductPart::where('key', $key)->first();
} }
$paginator = ProductPartSku::with('sku:id,name,cover,sell_price,vip_price') $paginator = ProductPartSku::with('sku:id,name,cover,sell_price,vip_price,market_price')
->whereHas('sku', function ($query) { ->whereHas('sku', function ($query) {
return $query->online(); return $query->online();
}) })

View File

@ -55,4 +55,9 @@ class ProductCategory extends Model
{ {
return $this->parent_id; return $this->parent_id;
} }
public function parent()
{
return $this->belongsTo(ProductCategory::class, 'parent_id');
}
} }