init
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled

This commit is contained in:
jiangdong.cheng
2026-02-11 17:28:36 +08:00
parent dcb82557c7
commit aa16c9f8c2
162 changed files with 22333 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Admin;
use App\Enums\EntityStatus;
use App\Enums\SourceLevel;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ArticleRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$articleId = $this->route('article')?->id;
return [
'category_id' => ['nullable', 'integer', 'exists:categories,id'],
'source_id' => ['nullable', 'integer', 'exists:sources,id'],
'title' => ['required', 'string', 'max:200'],
'slug' => ['required', 'string', 'max:190', Rule::unique('articles', 'slug')->ignore($articleId)],
'excerpt' => ['required', 'string', 'max:320'],
'body' => ['required', 'string', 'min:100'],
'source_name' => ['nullable', 'string', 'max:160'],
'source_url' => ['nullable', 'url', 'max:2048'],
'source_level' => ['required', Rule::in(array_column(SourceLevel::cases(), 'value'))],
'last_verified_at' => ['nullable', 'date'],
'status' => ['required', Rule::in(array_column(EntityStatus::cases(), 'value'))],
'is_stale' => ['nullable', 'boolean'],
'stale_note' => ['nullable', 'string'],
'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'],
];
}
}