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:
Michal Kváček
2016-01-22 12:43:00 +01:00
parent 23c47ad6a3
commit 1ca787e482
2 changed files with 38 additions and 11 deletions
+33
View File
@@ -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'
];
}
}