52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php namespace App\Http\Requests\Users;
|
|
/**
|
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All rights reserved
|
|
*/
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
/**
|
|
* Actualizar usuario
|
|
*
|
|
* @author Moisés Cortés C <moises.cortes@notsoweb.com>
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
class UserUpdateRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return auth()->user()->hasPermissionTo('users.edit');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'paternal' => ['required', 'string', 'max:255'],
|
|
'maternal' => ['required', 'string', 'max:255'],
|
|
'username' => ['required', 'string', 'max:255', 'alpha_dash', Rule::unique('users')->ignore($this->route('user'))],
|
|
'phone' => ['nullable', 'numeric', 'digits:10'],
|
|
'roles' => ['nullable', 'array']
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'username.required' => 'El nombre de usuario es requerido',
|
|
'username.unique' => 'El nombre de usuario ya está en uso',
|
|
'username.alpha_dash' => 'El usuario solo puede contener letras, números, guiones y guiones bajos',
|
|
];
|
|
}
|
|
}
|