@@ 12-42 (lines=31) @@ | ||
9 | * |
|
10 | * @author Mahmoud Zalt <[email protected]> |
|
11 | */ |
|
12 | class AssignUserToRoleRequest extends Request |
|
13 | { |
|
14 | ||
15 | /** |
|
16 | * @return array |
|
17 | */ |
|
18 | public function rules() |
|
19 | { |
|
20 | return [ |
|
21 | 'roles_names' => 'required|exists:roles,name', |
|
22 | 'user_id' => 'required|exists:users,id', |
|
23 | ]; |
|
24 | } |
|
25 | ||
26 | public function all() |
|
27 | { |
|
28 | $data = parent::all(); |
|
29 | ||
30 | $data['user_id'] = $this->decodeThisId($data['user_id']); |
|
31 | ||
32 | return $data; |
|
33 | } |
|
34 | ||
35 | /** |
|
36 | * @return bool |
|
37 | */ |
|
38 | public function authorize() |
|
39 | { |
|
40 | return $this->user()->hasPermissionTo('manage-roles-permissions'); |
|
41 | } |
|
42 | } |
|
43 |
@@ 12-51 (lines=40) @@ | ||
9 | * |
|
10 | * @author Mahmoud Zalt <[email protected]> |
|
11 | */ |
|
12 | class ConfirmUserEmailRequest extends Request |
|
13 | { |
|
14 | ||
15 | /** |
|
16 | * Get the validation rules that apply to the request. |
|
17 | * |
|
18 | * @return array |
|
19 | */ |
|
20 | public function rules() |
|
21 | { |
|
22 | return [ |
|
23 | 'id' => 'required|integer', // url parameter |
|
24 | 'code' => 'required|min:35|max:45', // url parameter |
|
25 | ]; |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * Override the all() to automatically apply validation rules to the URL parameters |
|
30 | * |
|
31 | * @return array |
|
32 | */ |
|
33 | public function all() |
|
34 | { |
|
35 | $data = parent::all(); |
|
36 | $data['id'] = $this->route('id'); |
|
37 | $data['code'] = $this->route('code'); |
|
38 | ||
39 | return $data; |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * Determine if the user is authorized to make this request. |
|
44 | * |
|
45 | * @return bool |
|
46 | */ |
|
47 | public function authorize() |
|
48 | { |
|
49 | return true; |
|
50 | } |
|
51 | } |
|
52 |