34 lines
969 B
PHP
34 lines
969 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateSmsSenderRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->can('manage-settings') ?? false;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$pid = (int) $this->input('profile_id');
|
|
$id = (int) ($this->route('smsSender')?->id ?? 0);
|
|
|
|
return [
|
|
'profile_id' => ['required', 'integer', 'exists:sms_profiles,id'],
|
|
'sname' => [
|
|
'nullable', 'string', 'max:20',
|
|
Rule::unique('sms_senders', 'sname')
|
|
->ignore($id)
|
|
->where(fn ($q) => $q->where('profile_id', $pid)),
|
|
],
|
|
'phone_number' => ['nullable', 'string', 'max:30'],
|
|
'description' => ['nullable', 'string', 'max:190'],
|
|
'active' => ['sometimes', 'boolean'],
|
|
];
|
|
}
|
|
}
|