Deploy Ladill Events / deploy (push) Successful in 47s
Speakers require email, get a personal holding page with programme and stage links, auto-invites when programme hosts are saved, and manual send for events without a schedule; also fix wallet copy on event create and anchor attendee comms. Co-authored-by: Cursor <cursoragent@cursor.com>
102 lines
3.4 KiB
PHP
102 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Events;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\QrCode;
|
|
use App\Services\Events\EventSpeakerInviteService;
|
|
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 EventSpeakerInviteService $invites,
|
|
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);
|
|
|
|
$roster = $this->invites->rosterWithInviteState($event);
|
|
|
|
return view('events.speakers', [
|
|
'qrCode' => $event,
|
|
'roster' => $roster,
|
|
'programmeAssignments' => $this->speakers->programmeAssignments($event),
|
|
'programme' => $this->speakers->linkedProgramme($event),
|
|
'canManualInvite' => collect($roster)->mapWithKeys(fn ($speaker) => [
|
|
$speaker['email'] => $this->invites->canSendManualInvite($event, $speaker),
|
|
])->all(),
|
|
]);
|
|
}
|
|
|
|
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' => ['required_with:speakers.*.name', 'email', 'max:190'],
|
|
'speakers.*.role' => ['nullable', 'string', 'max:80'],
|
|
'speakers.*.bio' => ['nullable', 'string', 'max:500'],
|
|
]);
|
|
|
|
try {
|
|
$this->manager->update($event, [
|
|
'speakers' => $validated['speakers'] ?? [],
|
|
]);
|
|
} catch (\RuntimeException $e) {
|
|
return back()->withInput()->with('error', $e->getMessage());
|
|
}
|
|
|
|
return redirect()
|
|
->route('speakers.show', $event)
|
|
->with('success', 'Speaker roster saved.');
|
|
}
|
|
|
|
public function sendInvite(Request $request, QrCode $event): RedirectResponse
|
|
{
|
|
$this->authorize('update', $event);
|
|
abort_unless($event->type === QrCode::TYPE_EVENT, 404);
|
|
|
|
$validated = $request->validate([
|
|
'email' => ['required', 'email', 'max:190'],
|
|
]);
|
|
|
|
$sent = $this->invites->sendManualInvite($event, $event->user, $validated['email']);
|
|
|
|
if (! $sent) {
|
|
return back()->with('error', 'Could not send invitation. Check the email address or whether this speaker was already invited from the programme.');
|
|
}
|
|
|
|
return back()->with('success', 'Speaker invitation sent.');
|
|
}
|
|
}
|