refactor(bootstrap): separate event category data
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Domains\Core\Tenant\Resources;
|
||||
|
||||
use App\Shared\Attachable\Models\Attachment;
|
||||
use App\Shared\Attachable\Models\AttachmentCrop;
|
||||
use App\Domains\Commerce\Catalog\Models\Category;
|
||||
use App\Domains\Ticketing\Event\Models\EventDate;
|
||||
use App\Domains\Ticketing\Event\Models\Event;
|
||||
use App\Domains\Ticketing\Event\Services\EventDateInfoFormatter;
|
||||
use App\Domains\Core\Menu\Models\Menu;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use App\Domains\Ticketing\Event\Models\Event;
|
||||
use App\Domains\Ticketing\Event\Models\EventDate;
|
||||
use App\Domains\Ticketing\Event\Services\EventDateInfoFormatter;
|
||||
use App\Shared\Attachable\Models\Attachment;
|
||||
use App\Shared\Attachable\Models\AttachmentCrop;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -99,14 +99,19 @@ class TenantResource extends JsonResource
|
||||
'menues',
|
||||
fn () => $this->menuTree($this->menues)
|
||||
),
|
||||
'categories' => $this->storefront_website_type_code === 'onticket_multi_event'
|
||||
? $this->whenLoaded('eventCategories', fn () => $this->eventCategories
|
||||
'categories' => $this->when(
|
||||
$this->storefront_website_type_code !== 'onticket_multi_event',
|
||||
fn () => $this->whenLoaded('categories', fn () => $this->categoryTree($this->categories))
|
||||
),
|
||||
'event_categories' => $this->when(
|
||||
$this->storefront_website_type_code === 'onticket_multi_event',
|
||||
fn () => $this->whenLoaded('eventCategories', fn () => $this->eventCategories
|
||||
->map(fn ($category) => [
|
||||
'id' => $category->id,
|
||||
'nombre' => $category->nombre,
|
||||
'subcategories' => [],
|
||||
])->values())
|
||||
: $this->whenLoaded('categories', fn () => $this->categoryTree($this->categories)),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user