flexisip-account-manager/flexiapi/app/Http/Requests/UpdateAccountRequest.php
Timothée Jaussoin 585cc2f02c Split APP_EVERYONE_IS_ADMIN in two and introduce APP_ADMINS_MANAGE_MULTI_DOMAINS to allow admins to manage accounts accross the domains
Update the admins panels to allow domains to be edited
Update the tests
Update the dependencies
Complete the documentation
2022-01-04 16:40:24 +01:00

40 lines
1.2 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use App\Rules\WithoutSpaces;
class UpdateAccountRequest 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'));
})->ignore($this->route('id'), 'id'),
'filled',
],
'domain' => config('app.admins_manage_multi_domains') ? 'required' : '',
'email' => 'nullable|email',
'password_sha256' => 'nullable|min:3',
'phone' => [
'nullable',
Rule::unique('accounts', 'username')->where(function ($query) {
$query->where('domain', config('app.sip_domain'));
})->ignore($this->route('id'), 'id'),
Rule::unique('aliases', 'alias')->ignore($this->route('id'), 'account_id'),
new WithoutSpaces, 'starts_with:+'
]
];
}
}