feat: optimize category and product resource queries with eager loading and response formatting improvements
This commit is contained in:
@@ -26,7 +26,7 @@ class CategoryController extends Controller
|
||||
})
|
||||
->with(['parent', 'subCategories', 'tenant'])
|
||||
->orderByDesc('id')
|
||||
->paginateFromRequest()
|
||||
->get()
|
||||
)->response();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,11 @@ class ProductController extends Controller
|
||||
return ProductResource::collection(
|
||||
Product::query()
|
||||
->where('tenant_codigo', $tenant->codigo)
|
||||
->with(['attachments', 'brand', 'category'])
|
||||
->with([
|
||||
'attachments' => fn ($query) => $query->orderBy('attachments.id')->limit(1),
|
||||
'brand',
|
||||
'category',
|
||||
])
|
||||
->latest()
|
||||
->paginateFromRequest()
|
||||
)->response();
|
||||
|
||||
Reference in New Issue
Block a user