| @@ 13-39 (lines=27) @@ | ||
| 10 | * |
|
| 11 | * @package Acacha\Users\Http\Requests |
|
| 12 | */ |
|
| 13 | class CreateUserRequest extends FormRequest |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * Determine if the user is authorized to make this request. |
|
| 17 | * |
|
| 18 | * @return bool |
|
| 19 | */ |
|
| 20 | public function authorize() |
|
| 21 | { |
|
| 22 | return Auth::user()->can('create-users'); |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Get the validation rules that apply to the request. |
|
| 27 | * |
|
| 28 | * @return array |
|
| 29 | */ |
|
| 30 | public function rules() |
|
| 31 | { |
|
| 32 | return [ |
|
| 33 | 'name' => 'required|max:255', |
|
| 34 | 'username' => 'sometimes|required|max:255|unique:users', |
|
| 35 | 'email' => 'required|email|max:255|unique:users', |
|
| 36 | 'password' => 'required|min:6' |
|
| 37 | ]; |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 13-39 (lines=27) @@ | ||
| 10 | * |
|
| 11 | * @package Acacha\Users\Http\Requests |
|
| 12 | */ |
|
| 13 | class UpdateUserRequest extends FormRequest |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * Determine if the user is authorized to make this request. |
|
| 17 | * |
|
| 18 | * @return bool |
|
| 19 | */ |
|
| 20 | public function authorize() |
|
| 21 | { |
|
| 22 | return Auth::user()->can('edit-users'); |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Get the validation rules that apply to the request. |
|
| 27 | * |
|
| 28 | * @return array |
|
| 29 | */ |
|
| 30 | public function rules() |
|
| 31 | { |
|
| 32 | return [ |
|
| 33 | 'name' => 'sometimes|required|max:255', |
|
| 34 | 'username' => 'sometimes|required|max:255|unique:users', |
|
| 35 | 'email' => 'sometimes|required|email|max:255|unique:users', |
|
| 36 | 'password' => 'sometimes|required|min:6' |
|
| 37 | ]; |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 12-39 (lines=28) @@ | ||
| 9 | * |
|
| 10 | * @package Acacha\Users\Http\Requests |
|
| 11 | */ |
|
| 12 | class CreateUserWithTokenRequest extends FormRequest |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * Determine if the user is authorized to make this request. |
|
| 16 | * |
|
| 17 | * @return bool |
|
| 18 | */ |
|
| 19 | public function authorize() |
|
| 20 | { |
|
| 21 | return true; |
|
| 22 | } |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Get the validation rules that apply to the request. |
|
| 26 | * |
|
| 27 | * @return array |
|
| 28 | */ |
|
| 29 | public function rules() |
|
| 30 | { |
|
| 31 | return [ |
|
| 32 | 'name' => 'required|max:255', |
|
| 33 | 'username' => 'sometimes|required|max:255|unique:users', |
|
| 34 | 'email' => 'required|email|max:255|unique:users', |
|
| 35 | 'password' => 'required|min:6', |
|
| 36 | 'token' => 'required' |
|
| 37 | ]; |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||