init
This commit is contained in:
52
app/Http/Requests/Admin/AiModelRequest.php
Normal file
52
app/Http/Requests/Admin/AiModelRequest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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 AiModelRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$modelId = $this->route('model')?->id;
|
||||
|
||||
return [
|
||||
'category_id' => ['nullable', 'integer', 'exists:categories,id'],
|
||||
'source_id' => ['nullable', 'integer', 'exists:sources,id'],
|
||||
'name' => ['required', 'string', 'max:160'],
|
||||
'slug' => ['required', 'string', 'max:190', Rule::unique('ai_models', 'slug')->ignore($modelId)],
|
||||
'provider' => ['nullable', 'string', 'max:120'],
|
||||
'summary' => ['required', 'string', 'max:260'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'modality' => ['required', 'string', 'max:64'],
|
||||
'context_window' => ['nullable', 'integer', 'min:1'],
|
||||
'price_input' => ['nullable', 'numeric', 'min:0'],
|
||||
'price_output' => ['nullable', 'numeric', 'min:0'],
|
||||
'deployment_mode' => ['required', 'string', 'max:32'],
|
||||
'effectiveness_score' => ['required', 'integer', 'between:0,100'],
|
||||
'price_score' => ['required', 'integer', 'between:0,100'],
|
||||
'speed_score' => ['required', 'integer', 'between:0,100'],
|
||||
'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'],
|
||||
'alternative_model_id' => ['nullable', 'integer', 'exists:ai_models,id'],
|
||||
'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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Http/Requests/Admin/ArticleRequest.php
Normal file
44
app/Http/Requests/Admin/ArticleRequest.php
Normal 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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
41
app/Http/Requests/Admin/CategoryRequest.php
Normal file
41
app/Http/Requests/Admin/CategoryRequest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CategoryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$categoryId = $this->route('category')?->id;
|
||||
|
||||
return [
|
||||
'type' => ['required', Rule::in($this->typeOptions())],
|
||||
'name' => ['required', 'string', 'max:120'],
|
||||
'slug' => ['required', 'string', 'max:190', Rule::unique('categories', 'slug')->ignore($categoryId)],
|
||||
'description' => ['nullable', 'string'],
|
||||
'is_active' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function typeOptions(): array
|
||||
{
|
||||
$defaults = ['tool', 'model', 'news', 'guide'];
|
||||
$existing = Category::query()->distinct()->pluck('type')->filter()->values()->all();
|
||||
|
||||
return array_values(array_unique([...$defaults, ...$existing]));
|
||||
}
|
||||
}
|
||||
37
app/Http/Requests/Admin/GuideRequest.php
Normal file
37
app/Http/Requests/Admin/GuideRequest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/Admin/SourceRequest.php
Normal file
32
app/Http/Requests/Admin/SourceRequest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use App\Enums\SourceLevel;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class SourceRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$sourceId = $this->route('source')?->id;
|
||||
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:150'],
|
||||
'domain' => ['required', 'string', 'max:255', Rule::unique('sources', 'domain')->ignore($sourceId)],
|
||||
'type' => ['required', 'string', 'max:32'],
|
||||
'trust_level' => ['required', Rule::in(array_column(SourceLevel::cases(), 'value'))],
|
||||
'is_whitelisted' => ['nullable', 'boolean'],
|
||||
'crawl_allowed' => ['nullable', 'boolean'],
|
||||
'note' => ['nullable', 'string'],
|
||||
];
|
||||
}
|
||||
}
|
||||
49
app/Http/Requests/Admin/ToolRequest.php
Normal file
49
app/Http/Requests/Admin/ToolRequest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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 ToolRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$toolId = $this->route('tool')?->id;
|
||||
|
||||
return [
|
||||
'category_id' => ['nullable', 'integer', 'exists:categories,id'],
|
||||
'source_id' => ['nullable', 'integer', 'exists:sources,id'],
|
||||
'name' => ['required', 'string', 'max:160'],
|
||||
'slug' => ['required', 'string', 'max:190', Rule::unique('tools', 'slug')->ignore($toolId)],
|
||||
'summary' => ['required', 'string', 'max:260'],
|
||||
'description' => ['nullable', 'string'],
|
||||
'official_url' => ['nullable', 'url', 'max:2048'],
|
||||
'logo_url' => ['nullable', 'url', 'max:2048'],
|
||||
'pricing_type' => ['required', 'string', 'max:32'],
|
||||
'platform' => ['nullable', 'string', 'max:64'],
|
||||
'language' => ['nullable', 'string', 'max:64'],
|
||||
'has_api' => ['nullable', 'boolean'],
|
||||
'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'],
|
||||
'alternative_tool_id' => ['nullable', 'integer', 'exists:tools,id'],
|
||||
'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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user