| @@ 12-63 (lines=52) @@ | ||
| 9 | * |
|
| 10 | * @author Mahmoud Zalt <[email protected]> |
|
| 11 | */ |
|
| 12 | class DeleteRoleRequest extends Request |
|
| 13 | { |
|
| 14 | ||
| 15 | /** |
|
| 16 | * Define which Roles and/or Permissions has access to this request. |
|
| 17 | * |
|
| 18 | * @var array |
|
| 19 | */ |
|
| 20 | protected $access = [ |
|
| 21 | 'roles' => 'admin', |
|
| 22 | 'permissions' => '', |
|
| 23 | ]; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Id's that needs decoding before applying the validation rules. |
|
| 27 | * |
|
| 28 | * @var array |
|
| 29 | */ |
|
| 30 | protected $decode = [ |
|
| 31 | 'id', |
|
| 32 | ]; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Defining the URL parameters (`/stores/999/items`) allows applying |
|
| 36 | * validation rules on them and allows accessing them like request data. |
|
| 37 | * |
|
| 38 | * @var array |
|
| 39 | */ |
|
| 40 | protected $urlParameters = [ |
|
| 41 | 'id', |
|
| 42 | ]; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return array |
|
| 46 | */ |
|
| 47 | public function rules() |
|
| 48 | { |
|
| 49 | return [ |
|
| 50 | 'id' => 'required|exists:roles,id' |
|
| 51 | ]; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @return bool |
|
| 56 | */ |
|
| 57 | public function authorize() |
|
| 58 | { |
|
| 59 | return $this->check([ |
|
| 60 | 'hasAccess', |
|
| 61 | ]); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| @@ 12-63 (lines=52) @@ | ||
| 9 | * |
|
| 10 | * @author Mahmoud Zalt <[email protected]> |
|
| 11 | */ |
|
| 12 | class GetPermissionRequest extends Request |
|
| 13 | { |
|
| 14 | ||
| 15 | /** |
|
| 16 | * Define which Roles and/or Permissions has access to this request. |
|
| 17 | * |
|
| 18 | * @var array |
|
| 19 | */ |
|
| 20 | protected $access = [ |
|
| 21 | 'roles' => 'admin', |
|
| 22 | 'permissions' => '', |
|
| 23 | ]; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Id's that needs decoding before applying the validation rules. |
|
| 27 | * |
|
| 28 | * @var array |
|
| 29 | */ |
|
| 30 | protected $decode = [ |
|
| 31 | 'id', |
|
| 32 | ]; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Defining the URL parameters (`/stores/999/items`) allows applying |
|
| 36 | * validation rules on them and allows accessing them like request data. |
|
| 37 | * |
|
| 38 | * @var array |
|
| 39 | */ |
|
| 40 | protected $urlParameters = [ |
|
| 41 | 'id', |
|
| 42 | ]; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return array |
|
| 46 | */ |
|
| 47 | public function rules() |
|
| 48 | { |
|
| 49 | return [ |
|
| 50 | 'id' => 'required|exists:permissions,id' |
|
| 51 | ]; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @return bool |
|
| 56 | */ |
|
| 57 | public function authorize() |
|
| 58 | { |
|
| 59 | return $this->check([ |
|
| 60 | 'hasAccess', |
|
| 61 | ]); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| @@ 12-63 (lines=52) @@ | ||
| 9 | * |
|
| 10 | * @author Mahmoud Zalt <[email protected]> |
|
| 11 | */ |
|
| 12 | class GetRoleRequest extends Request |
|
| 13 | { |
|
| 14 | ||
| 15 | /** |
|
| 16 | * Define which Roles and/or Permissions has access to this request. |
|
| 17 | * |
|
| 18 | * @var array |
|
| 19 | */ |
|
| 20 | protected $access = [ |
|
| 21 | 'roles' => 'admin', |
|
| 22 | 'permissions' => '', |
|
| 23 | ]; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Id's that needs decoding before applying the validation rules. |
|
| 27 | * |
|
| 28 | * @var array |
|
| 29 | */ |
|
| 30 | protected $decode = [ |
|
| 31 | 'id', |
|
| 32 | ]; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Defining the URL parameters (`/stores/999/items`) allows applying |
|
| 36 | * validation rules on them and allows accessing them like request data. |
|
| 37 | * |
|
| 38 | * @var array |
|
| 39 | */ |
|
| 40 | protected $urlParameters = [ |
|
| 41 | 'id', |
|
| 42 | ]; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return array |
|
| 46 | */ |
|
| 47 | public function rules() |
|
| 48 | { |
|
| 49 | return [ |
|
| 50 | 'id' => 'required|exists:roles,id' |
|
| 51 | ]; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @return bool |
|
| 56 | */ |
|
| 57 | public function authorize() |
|
| 58 | { |
|
| 59 | return $this->check([ |
|
| 60 | 'hasAccess', |
|
| 61 | ]); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| @@ 12-63 (lines=52) @@ | ||
| 9 | * |
|
| 10 | * @author Mahmoud Zalt <[email protected]> |
|
| 11 | */ |
|
| 12 | class DeleteUserRequest extends Request |
|
| 13 | { |
|
| 14 | ||
| 15 | /** |
|
| 16 | * Define which Roles and/or Permissions has access to this request. |
|
| 17 | * |
|
| 18 | * @var array |
|
| 19 | */ |
|
| 20 | protected $access = [ |
|
| 21 | 'permissions' => 'delete-users', |
|
| 22 | 'roles' => 'admin', |
|
| 23 | ]; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Id's that needs decoding before applying the validation rules. |
|
| 27 | * |
|
| 28 | * @var array |
|
| 29 | */ |
|
| 30 | protected $decode = [ |
|
| 31 | 'id', |
|
| 32 | ]; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Defining the URL parameters (`/stores/999/items`) allows applying |
|
| 36 | * validation rules on them and allows accessing them like request data. |
|
| 37 | * |
|
| 38 | * @var array |
|
| 39 | */ |
|
| 40 | protected $urlParameters = [ |
|
| 41 | 'id', |
|
| 42 | ]; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return array |
|
| 46 | */ |
|
| 47 | public function rules() |
|
| 48 | { |
|
| 49 | return [ |
|
| 50 | 'id' => 'required|exists:users,id', |
|
| 51 | ]; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @return bool |
|
| 56 | */ |
|
| 57 | public function authorize() |
|
| 58 | { |
|
| 59 | return $this->check([ |
|
| 60 | 'hasAccess|isOwner', |
|
| 61 | ]); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| @@ 12-63 (lines=52) @@ | ||
| 9 | * |
|
| 10 | * @author Mahmoud Zalt <[email protected]> |
|
| 11 | */ |
|
| 12 | class GetUserRequest extends Request |
|
| 13 | { |
|
| 14 | ||
| 15 | /** |
|
| 16 | * Define which Roles and/or Permissions has access to this request. |
|
| 17 | * |
|
| 18 | * @var array |
|
| 19 | */ |
|
| 20 | protected $access = [ |
|
| 21 | 'permissions' => 'find-users', |
|
| 22 | 'roles' => 'admin', |
|
| 23 | ]; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Id's that needs decoding before applying the validation rules. |
|
| 27 | * |
|
| 28 | * @var array |
|
| 29 | */ |
|
| 30 | protected $decode = [ |
|
| 31 | 'id', |
|
| 32 | ]; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Defining the URL parameters (`/stores/999/items`) allows applying |
|
| 36 | * validation rules on them and allows accessing them like request data. |
|
| 37 | * |
|
| 38 | * @var array |
|
| 39 | */ |
|
| 40 | protected $urlParameters = [ |
|
| 41 | 'id', |
|
| 42 | ]; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return array |
|
| 46 | */ |
|
| 47 | public function rules() |
|
| 48 | { |
|
| 49 | return [ |
|
| 50 | 'id' => 'required|exists:users,id' |
|
| 51 | ]; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @return bool |
|
| 56 | */ |
|
| 57 | public function authorize() |
|
| 58 | { |
|
| 59 | return $this->check([ |
|
| 60 | 'hasAccess|isOwner', |
|
| 61 | ]); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| @@ 12-64 (lines=53) @@ | ||
| 9 | * |
|
| 10 | * @author Mahmoud Zalt <[email protected]> |
|
| 11 | */ |
|
| 12 | class RefreshUserRequest extends Request |
|
| 13 | { |
|
| 14 | ||
| 15 | /** |
|
| 16 | * Define which Roles and/or Permissions has access to this request. |
|
| 17 | * |
|
| 18 | * @var array |
|
| 19 | */ |
|
| 20 | protected $access = [ |
|
| 21 | 'permissions' => '', |
|
| 22 | 'roles' => 'admin', |
|
| 23 | ]; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Id's that needs decoding before applying the validation rules. |
|
| 27 | * |
|
| 28 | * @var array |
|
| 29 | */ |
|
| 30 | protected $decode = [ |
|
| 31 | 'id', |
|
| 32 | ]; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Defining the URL parameters (`/stores/999/items`) allows applying |
|
| 36 | * validation rules on them and allows accessing them like request data. |
|
| 37 | * |
|
| 38 | * @var array |
|
| 39 | */ |
|
| 40 | protected $urlParameters = [ |
|
| 41 | 'id', |
|
| 42 | ]; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return array |
|
| 46 | */ |
|
| 47 | public function rules() |
|
| 48 | { |
|
| 49 | return [ |
|
| 50 | 'id' => 'required|exists:users,id' |
|
| 51 | ]; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @return bool |
|
| 56 | */ |
|
| 57 | public function authorize() |
|
| 58 | { |
|
| 59 | return $this->check([ |
|
| 60 | 'hasAccess|isOwner', |
|
| 61 | ]); |
|
| 62 | } |
|
| 63 | ||
| 64 | } |
|
| 65 | ||