Files
ai-web/app/Http/Requests/Admin/GuideRequest.php

38 lines
1.2 KiB
PHP
Raw Normal View History

2026-02-11 17:28:36 +08:00
<?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'],
];
}
}