Files
wticreatorstudio/Modules/Chat/Http/Requests/CreateUserRequest.php
T
2024-02-12 22:54:20 -05:00

54 lines
1.2 KiB
PHP

<?php
namespace Modules\Chat\Http\Requests;
use Modules\Chat\Entities\User;
use Illuminate\Foundation\Http\FormRequest;
class CreateUserRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
protected function prepareForValidation()
{
$this->sanitize();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = User::$rules;
$rules['email'] = 'required|email|max:255|regex:/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix|unique:users';
$rules['password'] = 'required|string|min:8|max:30|confirmed';
return $rules;
}
public function messages()
{
return User::$messages;
}
public function sanitize()
{
$input = $this->all();
$input['name'] = htmlspecialchars($input['name']);
$input['about'] = htmlspecialchars($input['about']);
$this->replace($input);
}
}