You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
817 B
32 lines
817 B
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\AudienceRegistration;
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
class AudienceTicketShortLinkController extends Controller
|
|
{
|
|
public function __invoke(string $ticket): RedirectResponse
|
|
{
|
|
$code = trim($ticket);
|
|
if ($code === '' || strlen($code) > 64) {
|
|
abort(404);
|
|
}
|
|
|
|
$row = AudienceRegistration::query()
|
|
->with('competition')
|
|
->where('ticket_code', $code)
|
|
->first();
|
|
|
|
if ($row === null || ! $row->isApproved() || $row->competition === null) {
|
|
abort(404);
|
|
}
|
|
|
|
$slug = rawurlencode((string) $row->competition->slug);
|
|
$encoded = rawurlencode((string) $row->ticket_code);
|
|
|
|
return redirect("/admin/c/{$slug}/t/{$encoded}");
|
|
}
|
|
}
|