fixed event join token handling in the event admin. created new seeders with new tenants and package purchases. added new playwright test scenarios.
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\Event;
|
||||
use App\Support\JoinTokenLayoutRegistry;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class EventJoinTokenResource extends JsonResource
|
||||
{
|
||||
@@ -18,23 +19,25 @@ class EventJoinTokenResource extends JsonResource
|
||||
$eventFromRoute = $request->route('event');
|
||||
$eventContext = $eventFromRoute instanceof Event ? $eventFromRoute : ($this->resource->event ?? null);
|
||||
|
||||
$layouts = $eventContext
|
||||
? JoinTokenLayoutRegistry::toResponse(function (string $layoutId, string $format) use ($eventContext) {
|
||||
$layouts = [];
|
||||
if ($eventContext && Route::has('tenant.events.join-tokens.layouts.download')) {
|
||||
$layouts = JoinTokenLayoutRegistry::toResponse(function (string $layoutId, string $format) use ($eventContext) {
|
||||
return route('tenant.events.join-tokens.layouts.download', [
|
||||
'event' => $eventContext,
|
||||
'joinToken' => $this->resource,
|
||||
'layout' => $layoutId,
|
||||
'format' => $format,
|
||||
]);
|
||||
})
|
||||
: [];
|
||||
});
|
||||
}
|
||||
|
||||
$layoutsUrl = $eventContext
|
||||
? route('tenant.events.join-tokens.layouts.index', [
|
||||
$layoutsUrl = null;
|
||||
if ($eventContext && Route::has('tenant.events.join-tokens.layouts.index')) {
|
||||
$layoutsUrl = route('tenant.events.join-tokens.layouts.index', [
|
||||
'event' => $eventContext,
|
||||
'joinToken' => $this->resource,
|
||||
])
|
||||
: null;
|
||||
]);
|
||||
}
|
||||
|
||||
$plainToken = $this->resource->plain_token ?? $this->token;
|
||||
|
||||
@@ -50,7 +53,7 @@ class EventJoinTokenResource extends JsonResource
|
||||
'revoked_at' => optional($this->revoked_at)->toIso8601String(),
|
||||
'is_active' => $this->isActive(),
|
||||
'created_at' => optional($this->created_at)->toIso8601String(),
|
||||
'metadata' => $this->metadata ?? new \stdClass(),
|
||||
'metadata' => $this->metadata ?? new \stdClass,
|
||||
'layouts_url' => $layoutsUrl,
|
||||
'layouts' => $layouts,
|
||||
];
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Resources\Tenant;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Resources\MissingValue;
|
||||
|
||||
class EventResource extends JsonResource
|
||||
{
|
||||
@@ -12,6 +13,21 @@ class EventResource extends JsonResource
|
||||
$tenantId = $request->attributes->get('tenant_id');
|
||||
$showSensitive = $this->tenant_id === $tenantId;
|
||||
$settings = is_array($this->settings) ? $this->settings : [];
|
||||
$eventPackage = null;
|
||||
|
||||
if ($this->relationLoaded('eventPackages')) {
|
||||
$related = $this->getRelation('eventPackages');
|
||||
|
||||
if (! $related instanceof MissingValue) {
|
||||
$eventPackage = $related->first();
|
||||
}
|
||||
} elseif ($this->relationLoaded('eventPackage')) {
|
||||
$related = $this->getRelation('eventPackage');
|
||||
|
||||
if (! $related instanceof MissingValue) {
|
||||
$eventPackage = $related;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
@@ -36,6 +52,13 @@ class EventResource extends JsonResource
|
||||
'is_public' => $this->status === 'published',
|
||||
'public_share_url' => null,
|
||||
'qr_code_url' => null,
|
||||
'package' => $eventPackage ? [
|
||||
'id' => $eventPackage->package_id,
|
||||
'name' => $eventPackage->package?->getNameForLocale(app()->getLocale()) ?? $eventPackage->package?->name,
|
||||
'price' => $eventPackage->purchased_price,
|
||||
'purchased_at' => $eventPackage->purchased_at?->toIso8601String(),
|
||||
'expires_at' => $eventPackage->gallery_expires_at?->toIso8601String(),
|
||||
] : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,15 +14,19 @@ class EventTypeResource extends JsonResource
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$nameTranslations = is_array($this->name) ? $this->name : [];
|
||||
$fallbackName = is_string($this->name) ? $this->name : '';
|
||||
$localizedName = $nameTranslations[app()->getLocale()] ?? $nameTranslations['en'] ?? reset($nameTranslations) ?? $fallbackName;
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'slug' => $this->slug,
|
||||
'name' => $localizedName,
|
||||
'name_translations' => $nameTranslations,
|
||||
'icon' => $this->icon,
|
||||
'color' => $this->color,
|
||||
'is_active' => $this->is_active,
|
||||
'created_at' => $this->created_at->toISOString(),
|
||||
'updated_at' => $this->updated_at->toISOString(),
|
||||
'settings' => $this->settings ?? [],
|
||||
'created_at' => $this->created_at?->toISOString(),
|
||||
'updated_at' => $this->updated_at?->toISOString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user