feat: implement index methods for Accommodation, Entry, Food, and Merchandise controllers; add service methods for fetching current items
This commit is contained in:
@@ -20,6 +20,20 @@ class AccommodationService
|
||||
{
|
||||
private const ATTRIBUTE_CODE = 'tipo_alojamiento';
|
||||
|
||||
public function current(Tenant $tenant): CatalogItem
|
||||
{
|
||||
return CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->where('slug', 'alojamiento')
|
||||
->with([
|
||||
'itemAttributes.attribute.options',
|
||||
'variants.catalogItem',
|
||||
'variants.inventory',
|
||||
'variants.definitions',
|
||||
])
|
||||
->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $variants
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,21 @@ class EntryService
|
||||
{
|
||||
public function __construct(private readonly CatalogService $catalogService) {}
|
||||
|
||||
/** @return Collection<int, CatalogItem> */
|
||||
public function all(Tenant $tenant): Collection
|
||||
{
|
||||
return CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->where('event_product_type', EventProductType::Entry->value)
|
||||
->with([
|
||||
'variants.inventory',
|
||||
'variants.eventDate',
|
||||
'variants.eventDates',
|
||||
])
|
||||
->orderBy('id')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $entries
|
||||
* @return Collection<int, CatalogItem>
|
||||
|
||||
@@ -20,6 +20,21 @@ class FoodService
|
||||
{
|
||||
private const ATTRIBUTE_CODES = ['event_date', 'horario', 'servicio'];
|
||||
|
||||
public function current(Tenant $tenant): CatalogItem
|
||||
{
|
||||
return CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->where('slug', 'comida')
|
||||
->with([
|
||||
'variants.catalogItem',
|
||||
'variants.inventory',
|
||||
'variants.eventDate',
|
||||
'variants.eventDates',
|
||||
'variants.definitions.itemAttribute.attribute',
|
||||
])
|
||||
->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $variants
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,23 @@ class MerchandiseService
|
||||
{
|
||||
private const ATTRIBUTE_CODES = ['color', 'talle'];
|
||||
|
||||
/** @return Collection<int, CatalogItem> */
|
||||
public function all(Tenant $tenant): Collection
|
||||
{
|
||||
return CatalogItem::query()
|
||||
->where('tenant_code', $tenant->codigo)
|
||||
->where('event_product_type', EventProductType::Product->value)
|
||||
->whereHas('category', fn ($query) => $query->where('nombre', 'Merchandising'))
|
||||
->with([
|
||||
'itemAttributes.attribute.options',
|
||||
'variants.catalogItem',
|
||||
'variants.inventory',
|
||||
'variants.definitions',
|
||||
])
|
||||
->orderBy('id')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $items
|
||||
* @return Collection<int, CatalogItem>
|
||||
|
||||
Reference in New Issue
Block a user