implemented event package addons with filament resource, event-admin purchase path and notifications, showing up in purchase history

This commit is contained in:
Codex Agent
2025-11-21 11:25:45 +01:00
parent 07fe049b8a
commit 7a8d22a238
58 changed files with 3339 additions and 60 deletions

View File

@@ -6,6 +6,7 @@ use App\Services\Packages\PackageLimitEvaluator;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\MissingValue;
use Illuminate\Support\Arr;
class EventResource extends JsonResource
{
@@ -76,6 +77,34 @@ class EventResource extends JsonResource
'limits' => $eventPackage && $limitEvaluator
? $limitEvaluator->summarizeEventPackage($eventPackage)
: null,
'addons' => $eventPackage ? $this->formatAddons($eventPackage) : [],
];
}
protected function formatAddons(?\App\Models\EventPackage $eventPackage): array
{
if (! $eventPackage) {
return [];
}
$addons = $eventPackage->relationLoaded('addons')
? $eventPackage->addons
: $eventPackage->addons()->latest()->take(10)->get();
return $addons->map(function ($addon) {
return [
'id' => $addon->id,
'key' => $addon->addon_key,
'label' => $addon->metadata['label'] ?? null,
'status' => $addon->status,
'price_id' => $addon->price_id,
'transaction_id' => $addon->transaction_id,
'extra_photos' => (int) $addon->extra_photos,
'extra_guests' => (int) $addon->extra_guests,
'extra_gallery_days' => (int) $addon->extra_gallery_days,
'purchased_at' => $addon->purchased_at?->toIso8601String(),
'metadata' => Arr::only($addon->metadata ?? [], ['price_eur']),
];
})->all();
}
}