mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-15 02:07:56 -04:00
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\Chat\Http\Requests;
|
|
|
|
use Modules\Chat\Entities\User;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateUserRequest 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()
|
|
{
|
|
$id = $this->route('user')->id;
|
|
$rules = User::$rules;
|
|
$rules['email'] = 'required|email|max:255|unique:users,email,'.$id.'|regex:/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix';
|
|
|
|
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);
|
|
}
|
|
}
|