feat(addons): finalize event addon catalog and ai styling upgrade flow
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Http\Requests\Tenant\BillingAddonHistoryRequest;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventPackageAddon;
|
||||
use App\Models\PackagePurchase;
|
||||
use App\Services\Addons\EventAddonCatalog;
|
||||
use App\Services\LemonSqueezy\Exceptions\LemonSqueezyException;
|
||||
use App\Services\LemonSqueezy\LemonSqueezySubscriptionService;
|
||||
use Dompdf\Dompdf;
|
||||
@@ -22,6 +23,7 @@ class TenantBillingController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly LemonSqueezySubscriptionService $subscriptions,
|
||||
private readonly EventAddonCatalog $addonCatalog,
|
||||
) {}
|
||||
|
||||
public function transactions(Request $request): JsonResponse
|
||||
@@ -132,11 +134,19 @@ class TenantBillingController extends Controller
|
||||
->orderByDesc('created_at')
|
||||
->paginate($perPage, ['*'], 'page', $page);
|
||||
|
||||
$data = $paginator->getCollection()->map(function (EventPackageAddon $addon) {
|
||||
$addonLabels = collect($this->addonCatalog->all())
|
||||
->mapWithKeys(fn (array $addon, string $key): array => [$key => $addon['label'] ?? null])
|
||||
->all();
|
||||
|
||||
$data = $paginator->getCollection()->map(function (EventPackageAddon $addon) use ($addonLabels) {
|
||||
$label = $addon->metadata['label']
|
||||
?? ($addonLabels[$addon->addon_key] ?? null)
|
||||
?? $addon->addon_key;
|
||||
|
||||
return [
|
||||
'id' => $addon->id,
|
||||
'addon_key' => $addon->addon_key,
|
||||
'label' => $addon->metadata['label'] ?? null,
|
||||
'label' => $label,
|
||||
'quantity' => (int) ($addon->quantity ?? 1),
|
||||
'status' => $addon->status,
|
||||
'amount' => $addon->amount !== null ? (float) $addon->amount : null,
|
||||
|
||||
Reference in New Issue
Block a user