- Updated the User model to implement Filament’s tenancy contracts - Seeded a ready-to-use demo tenant (user, tenant, active package, purchase) - Introduced a branded, translated 403 error page to replace the generic forbidden message for unauthorised admin hits - Removed the public “Register” links from the marketing header - hardened join event logic and improved error handling in the guest pwa.
56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Tenant;
|
|
|
|
use App\Models\Event;
|
|
use App\Support\JoinTokenLayoutRegistry;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class EventJoinTokenResource extends JsonResource
|
|
{
|
|
/**
|
|
* @param Request $request
|
|
*/
|
|
public function toArray($request): array
|
|
{
|
|
/** @var Event|null $eventFromRoute */
|
|
$eventFromRoute = $request->route('event');
|
|
$eventContext = $eventFromRoute instanceof Event ? $eventFromRoute : ($this->resource->event ?? null);
|
|
|
|
$layouts = $eventContext
|
|
? 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', [
|
|
'event' => $eventContext,
|
|
'joinToken' => $this->resource,
|
|
])
|
|
: null;
|
|
|
|
return [
|
|
'id' => $this->id,
|
|
'label' => $this->label,
|
|
'token' => $this->token,
|
|
'url' => url('/e/'.$this->token),
|
|
'usage_limit' => $this->usage_limit,
|
|
'usage_count' => $this->usage_count,
|
|
'expires_at' => optional($this->expires_at)->toIso8601String(),
|
|
'revoked_at' => optional($this->revoked_at)->toIso8601String(),
|
|
'is_active' => $this->isActive(),
|
|
'created_at' => optional($this->created_at)->toIso8601String(),
|
|
'metadata' => $this->metadata ?? new \stdClass(),
|
|
'layouts_url' => $layoutsUrl,
|
|
'layouts' => $layouts,
|
|
];
|
|
}
|
|
}
|