Fix post-registration 404, add speaker management, and simplify event creation.
Deploy Ladill Events / deploy (push) Successful in 28s
Deploy Ladill Events / deploy (push) Successful in 28s
Proxy registration transaction paths on Events, add a join button on the confirmation page, introduce speaker roster management, and replace the QR design wizard with merchant-style create/show flows. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Events;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\QrCode;
|
||||
use App\Services\Events\EventSpeakerService;
|
||||
use App\Services\Qr\QrCodeManagerService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SpeakerController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EventSpeakerService $speakers,
|
||||
private readonly QrCodeManagerService $manager,
|
||||
) {}
|
||||
|
||||
public function hub(Request $request): View
|
||||
{
|
||||
$account = ladill_account();
|
||||
$search = trim((string) $request->query('search', ''));
|
||||
|
||||
$events = $this->speakers->eventsForAccount($account->id, $search !== '' ? $search : null)
|
||||
->map(function (QrCode $event) {
|
||||
$event->speaker_count = count($this->speakers->rosterFor($event));
|
||||
|
||||
return $event;
|
||||
});
|
||||
|
||||
return view('events.speakers-hub', [
|
||||
'events' => $events,
|
||||
'search' => $search,
|
||||
]);
|
||||
}
|
||||
|
||||
public function index(QrCode $event): View
|
||||
{
|
||||
$this->authorize('view', $event);
|
||||
abort_unless($event->type === QrCode::TYPE_EVENT, 404);
|
||||
|
||||
return view('events.speakers', [
|
||||
'qrCode' => $event,
|
||||
'roster' => (array) ($event->content()['speakers'] ?? []),
|
||||
'programmeAssignments' => $this->speakers->programmeAssignments($event),
|
||||
'programme' => $this->speakers->linkedProgramme($event),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, QrCode $event): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $event);
|
||||
abort_unless($event->type === QrCode::TYPE_EVENT, 404);
|
||||
|
||||
$validated = $request->validate([
|
||||
'speakers' => ['nullable', 'array'],
|
||||
'speakers.*.name' => ['nullable', 'string', 'max:120'],
|
||||
'speakers.*.email' => ['nullable', 'email', 'max:190'],
|
||||
'speakers.*.role' => ['nullable', 'string', 'max:80'],
|
||||
'speakers.*.bio' => ['nullable', 'string', 'max:500'],
|
||||
]);
|
||||
|
||||
$this->manager->update($event, [
|
||||
'speakers' => $validated['speakers'] ?? [],
|
||||
]);
|
||||
|
||||
return redirect()
|
||||
->route('speakers.show', $event)
|
||||
->with('success', 'Speaker roster saved.');
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,13 @@ class QrCodeController extends Controller
|
||||
$requestedType = QrCode::TYPE_EVENT;
|
||||
}
|
||||
|
||||
if ($requestedType === QrCode::TYPE_EVENT) {
|
||||
return view('events.create', [
|
||||
'pricePerQr' => QrWallet::pricePerQr(),
|
||||
'accountEventDefaults' => $qrSettings->resolvedEventDefaults(),
|
||||
]);
|
||||
}
|
||||
|
||||
return view('qr-codes.create', [
|
||||
'wallet' => $wallet,
|
||||
'requestedType' => $requestedType,
|
||||
@@ -213,6 +220,16 @@ class QrCodeController extends Controller
|
||||
->get(['id', 'label'])
|
||||
: collect();
|
||||
|
||||
if ($qrCode->type === QrCode::TYPE_EVENT) {
|
||||
return view('events.show', [
|
||||
'qrCode' => $qrCode,
|
||||
'previewDataUri' => $previewDataUri,
|
||||
'itineraryOptions' => $itineraryOptions,
|
||||
'customDomains' => \App\Models\CustomDomain::where('qr_code_id', $qrCode->id)->get(),
|
||||
'customDomainsEnabled' => app(\App\Services\CustomDomain\CustomDomainService::class)->enabled(),
|
||||
]);
|
||||
}
|
||||
|
||||
return view('qr-codes.show', [
|
||||
'qrCode' => $qrCode,
|
||||
'previewDataUri' => $previewDataUri,
|
||||
|
||||
@@ -36,7 +36,7 @@ class RedirectLegacyQrToLadillLink
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if ($this->servesStoredAsset($request)) {
|
||||
if ($this->servesStoredAsset($request) || $this->servesRegistrationTransaction($request)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -64,4 +64,24 @@ class RedirectLegacyQrToLadillLink
|
||||
|
||||
return (bool) preg_match('#^(image/\d+|item-image/\d+/\d+)$#', $suffix);
|
||||
}
|
||||
|
||||
private function servesRegistrationTransaction(Request $request): bool
|
||||
{
|
||||
$shortCode = $request->route('shortCode');
|
||||
if (! is_string($shortCode) || $shortCode === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$path = ltrim($request->path(), '/');
|
||||
$prefix = 'q/'.$shortCode.'/';
|
||||
if (! str_starts_with($path, $prefix)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$suffix = substr($path, strlen($prefix));
|
||||
|
||||
return $suffix === 'register'
|
||||
|| str_starts_with($suffix, 'register/')
|
||||
|| str_starts_with($suffix, 'registered/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Events;
|
||||
|
||||
use App\Models\QrCode;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class EventSpeakerService
|
||||
{
|
||||
public function __construct(private readonly EventProgrammeService $programmes) {}
|
||||
|
||||
public function linkedProgramme(QrCode $event): ?QrCode
|
||||
{
|
||||
if ($event->type !== QrCode::TYPE_EVENT) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$programmeId = (int) ($event->content()['programme_qr_id'] ?? 0);
|
||||
if ($programmeId <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return QrCode::query()
|
||||
->where('id', $programmeId)
|
||||
->where('user_id', $event->user_id)
|
||||
->where('type', QrCode::TYPE_ITINERARY)
|
||||
->first();
|
||||
}
|
||||
|
||||
/** @return list<array{name: string, email: string, role: string, bio: string, source: string}> */
|
||||
public function rosterFor(QrCode $event): array
|
||||
{
|
||||
if ($event->type !== QrCode::TYPE_EVENT) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$content = $event->content();
|
||||
$roster = [];
|
||||
|
||||
foreach ((array) ($content['speakers'] ?? []) as $speaker) {
|
||||
if (! is_array($speaker)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name = trim((string) ($speaker['name'] ?? ''));
|
||||
if ($name === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$roster[] = [
|
||||
'name' => $name,
|
||||
'email' => trim((string) ($speaker['email'] ?? '')),
|
||||
'role' => trim((string) ($speaker['role'] ?? '')),
|
||||
'bio' => trim((string) ($speaker['bio'] ?? '')),
|
||||
'source' => 'roster',
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($this->programmeAssignments($event) as $assignment) {
|
||||
$name = trim((string) ($assignment['name'] ?? ''));
|
||||
if ($name === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$exists = collect($roster)->contains(fn ($row) => strcasecmp($row['name'], $name) === 0);
|
||||
if ($exists) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$roster[] = [
|
||||
'name' => $name,
|
||||
'email' => '',
|
||||
'role' => trim((string) ($assignment['session'] ?? '')),
|
||||
'bio' => '',
|
||||
'source' => 'programme',
|
||||
];
|
||||
}
|
||||
|
||||
return $roster;
|
||||
}
|
||||
|
||||
/** @return list<array{name: string, session: string, day: string, time: string}> */
|
||||
public function programmeAssignments(QrCode $event): array
|
||||
{
|
||||
$programme = $this->linkedProgramme($event);
|
||||
$snapshot = $this->programmes->snapshot($programme);
|
||||
if (! $snapshot) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$assignments = [];
|
||||
|
||||
foreach ((array) ($snapshot['days'] ?? []) as $day) {
|
||||
$dayLabel = trim((string) ($day['date'] ?? $day['label'] ?? ''));
|
||||
foreach ((array) ($day['items'] ?? []) as $item) {
|
||||
if (! is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$host = trim((string) ($item['host'] ?? ''));
|
||||
if ($host === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$assignments[] = [
|
||||
'name' => $host,
|
||||
'session' => trim((string) ($item['title'] ?? '')),
|
||||
'day' => $dayLabel,
|
||||
'time' => trim((string) ($item['time'] ?? '')),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $assignments;
|
||||
}
|
||||
|
||||
/** @return Collection<int, QrCode> */
|
||||
public function eventsForAccount(int $userId, ?string $search = null): Collection
|
||||
{
|
||||
return QrCode::query()
|
||||
->where('user_id', $userId)
|
||||
->where('type', QrCode::TYPE_EVENT)
|
||||
->when($search !== null && $search !== '', fn ($q) => $q->where('label', 'like', "%{$search}%"))
|
||||
->latest()
|
||||
->get();
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,11 @@ class QrCodeManagerService
|
||||
|
||||
$type = (string) ($data['type'] ?? '');
|
||||
$validated = $this->payloadValidator->validateForCreate($type, $data);
|
||||
$style = QrStyleDefaults::merge($data['style'] ?? null);
|
||||
$styleInput = $data['style'] ?? null;
|
||||
if ($type === QrCode::TYPE_EVENT && empty(array_filter((array) $styleInput))) {
|
||||
$styleInput = $user->getOrCreateQrSetting()->resolvedDefaultStyle();
|
||||
}
|
||||
$style = QrStyleDefaults::merge($styleInput);
|
||||
|
||||
return DB::transaction(function () use ($user, $wallet, $data, $type, $validated, $style) {
|
||||
$documentId = null;
|
||||
@@ -360,7 +364,7 @@ class QrCodeManagerService
|
||||
QrCode::TYPE_VCARD => ['first_name', 'last_name', 'phone', 'email', 'company', 'website', 'address', 'note', 'social'],
|
||||
QrCode::TYPE_BUSINESS => ['name', 'tagline', 'phone', 'email', 'website', 'address', 'hours'],
|
||||
QrCode::TYPE_CHURCH => ['name', 'denomination', 'description', 'phone', 'email', 'website', 'address', 'service_times', 'org_type', 'accepts_payment', 'collection_types', 'brand_color'],
|
||||
QrCode::TYPE_EVENT => ['name', 'tagline', 'description', 'location', 'starts_at', 'ends_at', 'organizer', 'website', 'brand_color', 'tiers', 'badge_fields', 'badge_size', 'registration_open', 'format', 'virtual_sessions'],
|
||||
QrCode::TYPE_EVENT => ['name', 'tagline', 'description', 'location', 'starts_at', 'ends_at', 'organizer', 'website', 'brand_color', 'tiers', 'badge_fields', 'badge_size', 'registration_open', 'format', 'virtual_sessions', 'speakers', 'programme_qr_id'],
|
||||
QrCode::TYPE_ITINERARY => ['title', 'subtitle', 'description', 'event_date', 'location', 'brand_color', 'days'],
|
||||
QrCode::TYPE_DOCUMENT => ['allow_download'],
|
||||
QrCode::TYPE_MENU => ['menu_title', 'sections', 'accepts_payment', 'brand_color', 'shipping_type', 'shipping_fee', 'free_shipping_above'],
|
||||
|
||||
@@ -265,6 +265,7 @@ class QrPayloadValidator
|
||||
: 'in_person';
|
||||
|
||||
$virtualSessions = $this->normalizeVirtualSessions($input['virtual_sessions'] ?? [], $format);
|
||||
$speakers = $this->normalizeSpeakers($input['speakers'] ?? null, $input);
|
||||
|
||||
// Contributions always take payment; ticketing only for paid tiers; free never.
|
||||
$acceptsPayment = match ($mode) {
|
||||
@@ -297,6 +298,7 @@ class QrPayloadValidator
|
||||
'programme_qr_id' => ($pid = (int) ($input['programme_qr_id'] ?? 0)) > 0 ? $pid : null,
|
||||
'format' => $format,
|
||||
'virtual_sessions' => $virtualSessions,
|
||||
'speakers' => $speakers,
|
||||
],
|
||||
'destination_url' => null,
|
||||
];
|
||||
@@ -352,6 +354,34 @@ class QrPayloadValidator
|
||||
return array_values($normalized);
|
||||
}
|
||||
|
||||
/** @return list<array{name: string, email: string, role: string, bio: string}> */
|
||||
private function normalizeSpeakers(mixed $speakers, array $input): array
|
||||
{
|
||||
$rows = is_array($speakers) ? $speakers : (array) ($input['speakers'] ?? []);
|
||||
$normalized = [];
|
||||
|
||||
foreach ($rows as $speaker) {
|
||||
if (! is_array($speaker)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name = trim((string) ($speaker['name'] ?? ''));
|
||||
if ($name === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$email = trim((string) ($speaker['email'] ?? ''));
|
||||
$normalized[] = [
|
||||
'name' => mb_substr($name, 0, 120),
|
||||
'email' => filter_var($email, FILTER_VALIDATE_EMAIL) ? $email : '',
|
||||
'role' => mb_substr(trim((string) ($speaker['role'] ?? '')), 0, 80),
|
||||
'bio' => mb_substr(trim((string) ($speaker['bio'] ?? '')), 0, 500),
|
||||
];
|
||||
}
|
||||
|
||||
return array_values($normalized);
|
||||
}
|
||||
|
||||
/** @param array<int, array{price: float}> $tiers */
|
||||
private function eventHasPaidTier(array $tiers): bool
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user