49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\AppUser;
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Validation\Rule;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class UpdateAppUserRequest extends StoreAppUserRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Gate::check('update', $this->route('app_user'));
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$rules = [
|
|
'email' => [
|
|
'required',
|
|
'min:3',
|
|
'max:255',
|
|
'email:rfc,dns',
|
|
Rule::unique('app_users', 'email')
|
|
->where('tenant_id', tenant('id'))
|
|
->ignore($this->route('app_user')->getKey()),
|
|
],
|
|
'password' => [
|
|
'sometimes', 'nullable', 'required_with:password_confirmation', 'confirmed', 'max:255',
|
|
Password::min(8)
|
|
->letters()
|
|
->mixedCase()
|
|
->numbers()
|
|
->symbols()
|
|
],
|
|
];
|
|
return array_merge(parent::rules(), $rules);
|
|
}
|
|
}
|