chore: update composer dependencies to include phppresentation chore: update composer.lock after adding phppresentation feat: create categories migration for category management feat: create templates migration for template storage feat: create template generations migration for tracking template usage feat: create template keys migration for template customization feat: create notifications migration for user notifications feat: update API routes for categories, templates, and user profile management docs: update API documentation to include new endpoints for profile and wallet
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api;
|
|
|
|
use App\Enums\TemplateKeyType;
|
|
use App\Models\Template;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class GenerateTemplateRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
/** @var Template $template */
|
|
$template = $this->route('template');
|
|
|
|
$rules = [];
|
|
|
|
foreach ($template->keys as $key) {
|
|
$fieldRules = [$key->is_required ? 'required' : 'nullable'];
|
|
|
|
$fieldRules[] = match ($key->type) {
|
|
TemplateKeyType::Text => 'string',
|
|
TemplateKeyType::Image => 'file|image',
|
|
TemplateKeyType::Chart => 'prohibited',
|
|
};
|
|
|
|
$rules['values.'.$key->key] = $fieldRules;
|
|
}
|
|
|
|
return $rules;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'*.prohibited' => 'کلید :attribute از نوع چارت است و فعلاً پشتیبانی نمیشود.',
|
|
];
|
|
}
|
|
}
|