e3bc5da7e3
Co-authored-by: Copilot <copilot@github.com>
36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreEmailPackageFromContractsRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->can('manage-settings') ?? false;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'type' => ['required', 'in:email'],
|
|
'name' => ['nullable', 'string', 'max:255'],
|
|
'description' => ['nullable', 'string'],
|
|
'meta' => ['nullable', 'array'],
|
|
|
|
// Common payload for all items
|
|
'payload' => ['required', 'array'],
|
|
'payload.mail_profile_id' => ['nullable', 'integer', 'exists:mail_profiles,id'],
|
|
'payload.template_id' => ['nullable', 'integer', 'exists:email_templates,id'],
|
|
'payload.subject' => ['nullable', 'string', 'max:255'],
|
|
'payload.body_text' => ['nullable', 'string', 'max:10000'],
|
|
'payload.variables' => ['nullable', 'array'],
|
|
|
|
// Source contracts to derive items from
|
|
'contract_ids' => ['required', 'array', 'min:1'],
|
|
'contract_ids.*' => ['integer', 'exists:contracts,id'],
|
|
];
|
|
}
|
|
}
|