38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Admin;
|
||
|
|
|
||
|
|
use App\Enums\EntityStatus;
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
use Illuminate\Validation\Rule;
|
||
|
|
|
||
|
|
class GuideRequest extends FormRequest
|
||
|
|
{
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
$guideId = $this->route('guide')?->id;
|
||
|
|
|
||
|
|
return [
|
||
|
|
'category_id' => ['nullable', 'integer', 'exists:categories,id'],
|
||
|
|
'title' => ['required', 'string', 'max:200'],
|
||
|
|
'slug' => ['required', 'string', 'max:190', Rule::unique('guides', 'slug')->ignore($guideId)],
|
||
|
|
'excerpt' => ['required', 'string', 'max:320'],
|
||
|
|
'body' => ['required', 'string', 'min:100'],
|
||
|
|
'difficulty' => ['required', 'string', 'max:32'],
|
||
|
|
'status' => ['required', Rule::in(array_column(EntityStatus::cases(), 'value'))],
|
||
|
|
'seo_title' => ['nullable', 'string', 'max:180'],
|
||
|
|
'seo_description' => ['nullable', 'string', 'max:320'],
|
||
|
|
'h1' => ['nullable', 'string', 'max:180'],
|
||
|
|
'canonical_url' => ['nullable', 'url', 'max:2048'],
|
||
|
|
'published_at' => ['nullable', 'date'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|