flexisip-account-manager/flexiapi/app/Http/Requests/CreateAccountRequest.php
Timothée Jaussoin 717d3e3cc9 Move the DTMF protocol from AccountAction to Account
Ensure that the account actions are not reachable if the account doesn't have the DTMF protocol configured
Update the documentation
Update the tests
Fix migration for SQLite
2022-01-20 15:29:48 +01:00

40 lines
1 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use App\Account;
use App\Rules\WithoutSpaces;
class CreateAccountRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'username' => [
'required',
Rule::unique('accounts', 'username')->where(function ($query) {
$query->where('domain', config('app.sip_domain'));
}),
'filled',
],
'domain' => config('app.admins_manage_multi_domains') ? 'required' : '',
'password' => 'required|min:3',
'email' => 'nullable|email',
'dtmf_protocol' => 'nullable|in:' . Account::dtmfProtocolsRule(),
'phone' => [
'nullable',
'unique:aliases,alias',
'unique:accounts,username',
new WithoutSpaces, 'starts_with:+'
]
];
}
}