Adds DELETE route, form request authorization, admin UI with confirm, Dutch strings, and feature tests. Made-with: Cursor
37 lines
864 B
PHP
37 lines
864 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Admin;
|
|
|
|
use App\Models\PreregistrationPage;
|
|
use App\Models\Subscriber;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class DestroySubscriberRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
$page = $this->route('page');
|
|
$subscriber = $this->route('subscriber');
|
|
if (! $page instanceof PreregistrationPage || ! $subscriber instanceof Subscriber) {
|
|
return false;
|
|
}
|
|
|
|
if ($subscriber->preregistration_page_id !== $page->id) {
|
|
return false;
|
|
}
|
|
|
|
return $this->user()?->can('update', $page) ?? false;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, array<int, ValidationRule|string>>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|