Refactor Catalog API: Remove Create Catalog Item Endpoint and Update Related Logic
- Removed the "Create Catalog" endpoint from the Postman collection. - Updated the CatalogController to handle tenant-specific catalog items based on active events. - Refactored CatalogItem model to automatically set event_id based on tenant's active_event_id during creation. - Deleted StoreCatalogItemRequest and CatalogItemResource as they are no longer needed. - Updated various services and controllers to utilize the new tenant-based catalog item retrieval logic. - Added tests to ensure that catalog reads are limited to items associated with the active event.
This commit is contained in:
@@ -22,7 +22,7 @@ class EntryService
|
||||
public function all(Tenant $tenant): Collection
|
||||
{
|
||||
return CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->forTenantCatalog($tenant)
|
||||
->whereHas('category', fn ($query) => $query->where('nombre', 'Entradas'))
|
||||
->whereHas('variants', fn ($query) => $query
|
||||
->whereNull('replaced_by_variant_id')
|
||||
@@ -84,7 +84,7 @@ class EntryService
|
||||
{
|
||||
$entry = CatalogItem::query()
|
||||
->whereKey($entryId)
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->forTenantCatalog($tenant)
|
||||
->whereHas('category', fn ($query) => $query->where('nombre', 'Entradas'))
|
||||
->firstOrFail();
|
||||
|
||||
@@ -96,7 +96,7 @@ class EntryService
|
||||
{
|
||||
$catalogItem = CatalogItem::query()
|
||||
->whereKey($entry['id'])
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->forTenantCatalog($tenant)
|
||||
->whereHas('category', fn ($query) => $query->where('nombre', 'Entradas'))
|
||||
->lockForUpdate()
|
||||
->firstOrFail();
|
||||
|
||||
Reference in New Issue
Block a user