FEATURE: add Request class for handling user registration
Laravel provides functionality for validating and authorization of incoming form requests. This commit adds this functionality to user registration.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\User;
|
||||
|
||||
class CreateNewUser extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return \Auth::$user->role == User::ROLE_ADMIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'role' => 'required',
|
||||
'email' => 'required|email|max:128|unique:users',
|
||||
'password' => 'required|min:6'
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user