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,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'],
];
}
}

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'],
];
}
}

View 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]));
}
}

View 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'],
];
}
}

View 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'],
];
}
}

View 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'],
];
}
}