32 lines
1.2 KiB
PHP
32 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreSmsTemplateRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->can('manage-settings') ?? false;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string', 'max:190'],
|
|
'slug' => ['required', 'string', 'max:190', 'alpha_dash', 'unique:sms_templates,slug'],
|
|
// Content is required unless template allows custom body
|
|
'content' => [Rule::requiredIf(fn () => ! (bool) $this->input('allow_custom_body')), 'nullable', 'string', 'max:1000'],
|
|
'variables_json' => ['nullable', 'array'],
|
|
'is_active' => ['sometimes', 'boolean'],
|
|
'default_profile_id' => ['nullable', 'integer', 'exists:sms_profiles,id'],
|
|
'default_sender_id' => ['nullable', 'integer', 'exists:sms_senders,id'],
|
|
'allow_custom_body' => ['sometimes', 'boolean'],
|
|
'action_id' => ['nullable', 'integer', 'exists:actions,id'],
|
|
'decision_id' => ['nullable', 'integer', 'exists:decisions,id'],
|
|
];
|
|
}
|
|
}
|