修复产品分类分页
This commit is contained in:
parent
d8abb038b0
commit
1768a7fb77
|
|
@ -48,7 +48,7 @@ class ProductRepo
|
|||
public static function getProductsByCategory($categoryId): AnonymousResourceCollection
|
||||
{
|
||||
$builder = self::getBuilder(['category_id' => $categoryId, 'active' => 1]);
|
||||
$products = $builder->with('inCurrentWishlist')->get();
|
||||
$products = $builder->with('inCurrentWishlist')->paginate();
|
||||
return ProductSimple::collection($products);
|
||||
}
|
||||
|
||||
|
|
@ -230,6 +230,7 @@ class ProductRepo
|
|||
->get();
|
||||
return $products;
|
||||
}
|
||||
|
||||
public static function DeleteByIds($ids)
|
||||
{
|
||||
Product::query()->whereIn('id', $ids)->delete();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ class CategoryController extends Controller
|
|||
|
||||
$data = [
|
||||
'category' => $category,
|
||||
'products' => $products->jsonSerialize(),
|
||||
'products_format' => $products->jsonSerialize(),
|
||||
'products' => $products,
|
||||
];
|
||||
|
||||
return view('category', $data);
|
||||
|
|
|
|||
|
|
@ -7,14 +7,17 @@
|
|||
<x-shop-breadcrumb type="category" :value="$category" />
|
||||
|
||||
<div class="row">
|
||||
@if (count($products))
|
||||
@foreach ($products as $product)
|
||||
@if (count($products_format))
|
||||
@foreach ($products_format as $product)
|
||||
<div class="col-6 col-md-3">@include('shared.product')</div>
|
||||
@endforeach
|
||||
@else
|
||||
<x-shop-no-data />
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{ $products->links('shared/pagination/bootstrap-4') }}
|
||||
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
Loading…
Reference in New Issue