feat: add ApiResponse trait for standardized API responses
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
This commit is contained in:
50
app/Http/Requests/Api/GenerateTemplateRequest.php
Normal file
50
app/Http/Requests/Api/GenerateTemplateRequest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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 از نوع چارت است و فعلاً پشتیبانی نمیشود.',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user