44 lines
938 B
PHP
44 lines
938 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Models\Project;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class DeleteProjectRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user() !== null;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
/** @var Project $project */
|
|
$project = $this->route('project');
|
|
|
|
return [
|
|
'confirmation_key' => [
|
|
'required',
|
|
'string',
|
|
Rule::in([$project->key]),
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'confirmation_key.in' => 'Enter the exact project key to confirm deletion.',
|
|
];
|
|
}
|
|
}
|