mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-15 02:07:56 -04:00
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Chat\Http\Requests;
|
|
|
|
use Modules\Chat\Entities\User;
|
|
use Auth;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateUserProfileRequest 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 = Auth::id();
|
|
$rules = [
|
|
'name' => 'required|string|max:100',
|
|
'email' => 'required|email|max:255|unique:users,email,'.$id.'|regex:/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix',
|
|
'phone' => 'nullable|integer',
|
|
'privacy' => 'required',
|
|
];
|
|
|
|
return $rules;
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return User::$messages;
|
|
}
|
|
|
|
public function sanitize()
|
|
{
|
|
$input = $this->all();
|
|
|
|
$input['name'] = htmlspecialchars($input['name']);
|
|
$input['about'] = isset($input['about']) ? htmlspecialchars($input['about']) : null;
|
|
|
|
$this->replace($input);
|
|
}
|
|
}
|