31 lines
966 B
PHP
31 lines
966 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateEmailTemplateRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->can('update', $this->route('emailTemplate')) ?? false;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$id = $this->route('emailTemplate')?->id;
|
|
|
|
return [
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'key' => ['required', 'string', 'max:255', 'unique:email_templates,key,'.$id],
|
|
'subject_template' => ['required', 'string', 'max:1000'],
|
|
'html_template' => ['nullable', 'string'],
|
|
'text_template' => ['nullable', 'string'],
|
|
'entity_types' => ['nullable', 'array'],
|
|
'entity_types.*' => ['string', 'in:client,client_case,contract,person'],
|
|
'allow_attachments' => ['sometimes', 'boolean'],
|
|
'active' => ['boolean'],
|
|
];
|
|
}
|
|
}
|