@@ -2,196 +2,196 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - 'success' => [ |
|
| 6 | - |
|
| 7 | - 'insert' => 'The requested parameter is Added successfully!', |
|
| 8 | - |
|
| 9 | - 'delete' => 'The requested parameter is deleted successfully!', |
|
| 10 | - |
|
| 11 | - 'update' => 'The requested parameter is updated successfully!' |
|
| 12 | - |
|
| 13 | - ], |
|
| 14 | - |
|
| 15 | - 'fail' => [ |
|
| 16 | - |
|
| 17 | - 'insert' => 'The requested parameter is not Added!', |
|
| 18 | - |
|
| 19 | - 'delete' => 'The requested parameter is not deleted!', |
|
| 20 | - |
|
| 21 | - 'update' => 'The requested parameter is not updated!' |
|
| 22 | - |
|
| 23 | - ], |
|
| 24 | - |
|
| 25 | - 1001 => [ |
|
| 26 | - 'message' => 'Oops... Requested failed is not found!', |
|
| 27 | - 'type' => 'error' |
|
| 28 | - ], |
|
| 29 | - |
|
| 30 | - 1002 => [ |
|
| 31 | - 'message' => 'Oops... Requested User does not exists!', |
|
| 32 | - 'type' => 'error' |
|
| 33 | - ], |
|
| 34 | - |
|
| 35 | - 1003 => [ |
|
| 36 | - 'message' => 'Oops... Client type is not entered!', |
|
| 37 | - 'type' => 'error' |
|
| 38 | - ], |
|
| 39 | - |
|
| 40 | - 1004 => [ |
|
| 41 | - 'message' => 'Failed because of duplicate', |
|
| 42 | - 'type' => 'error' |
|
| 43 | - ], |
|
| 44 | - |
|
| 45 | - 1005 => [ |
|
| 46 | - 'message' => 'Failed because of dablicated user role', |
|
| 47 | - 'type' => 'error' |
|
| 48 | - ], |
|
| 49 | - |
|
| 50 | - 3001 => [ |
|
| 51 | - 'message' => 'You are not logged on', |
|
| 52 | - 'type' => 'error', |
|
| 53 | - 'cat' => 'auth', |
|
| 54 | - 'short' => 'not-logged-on' |
|
| 55 | - ], |
|
| 56 | - |
|
| 57 | - 3002 => [ |
|
| 58 | - 'message' => 'Application token did not generated successfully', |
|
| 59 | - 'type' => 'error', |
|
| 60 | - 'cat' => 'auth' |
|
| 61 | - ], |
|
| 62 | - |
|
| 63 | - 3003 => [ |
|
| 64 | - 'message' => 'User token did not generated successfully', |
|
| 65 | - 'type' => 'error', |
|
| 66 | - 'cat' => 'auth' |
|
| 67 | - ], |
|
| 68 | - |
|
| 69 | - 3004 => [ |
|
| 70 | - 'message' => 'Request token have no agency access', |
|
| 71 | - 'type' => 'error', |
|
| 72 | - 'cat' => 'auth' |
|
| 73 | - ], |
|
| 74 | - |
|
| 75 | - 3005 => [ |
|
| 76 | - 'message' => 'Request token did not contains user information', |
|
| 77 | - 'type' => 'error', |
|
| 78 | - 'cat' => 'auth' |
|
| 79 | - ], |
|
| 80 | - |
|
| 81 | - 3006 => [ |
|
| 82 | - 'message' => 'Did not set request token', |
|
| 83 | - 'type' => 'error', |
|
| 84 | - 'cat' => 'auth' |
|
| 85 | - ], |
|
| 86 | - |
|
| 87 | - 3007 => [ |
|
| 88 | - 'message' => 'can not decode the token', |
|
| 89 | - 'type' => 'error', |
|
| 90 | - 'cat' => 'auth' |
|
| 91 | - ], |
|
| 92 | - |
|
| 93 | - 3008 => [ |
|
| 94 | - 'message' => 'can not generate token for authentication', |
|
| 95 | - 'type' => 'error', |
|
| 96 | - 'cat' => 'auth' |
|
| 97 | - ], |
|
| 98 | - |
|
| 99 | - 3009 => [ |
|
| 100 | - 'message' => 'can not create token', |
|
| 101 | - 'type' => 'error', |
|
| 102 | - 'cat' => 'auth' |
|
| 103 | - ], |
|
| 104 | - |
|
| 105 | - 3010 => [ |
|
| 106 | - 'message' => 'Token expired!', |
|
| 107 | - 'type' => 'error', |
|
| 108 | - 'cat' => 'auth' |
|
| 109 | - ], |
|
| 110 | - |
|
| 111 | - 3011 => [ |
|
| 112 | - 'message' => 'Token is invalid!', |
|
| 113 | - 'type' => 'error', |
|
| 114 | - 'cat' => 'auth' |
|
| 115 | - ], |
|
| 116 | - |
|
| 117 | - 3012 => [ |
|
| 118 | - 'message' => 'Token Blacklisted', |
|
| 119 | - 'type' => 'error', |
|
| 120 | - 'cat' => 'auth' |
|
| 121 | - ], |
|
| 122 | - |
|
| 123 | - 3013 => [ |
|
| 124 | - 'message' => 'Payload invalid!', |
|
| 125 | - 'type' => 'error', |
|
| 126 | - 'cat' => 'auth' |
|
| 127 | - ], |
|
| 128 | - |
|
| 129 | - 3014 => [ |
|
| 130 | - 'message' => 'Claim Invalid', |
|
| 131 | - 'type' => 'error', |
|
| 132 | - 'cat' => 'auth' |
|
| 133 | - ], |
|
| 134 | - |
|
| 135 | - 3015 => [ |
|
| 136 | - 'message' => 'An error occurred on token validation', |
|
| 137 | - 'type' => 'error', |
|
| 138 | - 'cat' => 'auth' |
|
| 139 | - ], |
|
| 140 | - |
|
| 141 | - 3016 => [ |
|
| 142 | - |
|
| 143 | - 'message' => 'This domain has been blocked', |
|
| 144 | - 'type' => 'error' |
|
| 145 | - ], |
|
| 146 | - |
|
| 147 | - 5401 => [ |
|
| 148 | - 'message' => 'Authentication unauthorized...', |
|
| 149 | - 'type' => 'error' |
|
| 150 | - ], |
|
| 151 | - |
|
| 152 | - 5404 => [ |
|
| 153 | - 'message' => 'Oops... The requested page not found!', |
|
| 154 | - 'type' => 'error' |
|
| 155 | - ], |
|
| 156 | - |
|
| 157 | - 5405 => [ |
|
| 158 | - 'message' => 'Oops... The method you requested is not allowed!', |
|
| 159 | - 'type' => 'error' |
|
| 160 | - ], |
|
| 161 | - |
|
| 162 | - 5406 => [ |
|
| 163 | - 'message' => 'Oops... The parameters you entered are wrong!', |
|
| 164 | - 'type' => 'error' |
|
| 165 | - ], |
|
| 166 | - |
|
| 167 | - 5420 => [ |
|
| 168 | - 'message' => 'Validation Error', |
|
| 169 | - 'type' => 'error' |
|
| 170 | - ], |
|
| 171 | - |
|
| 172 | - 5422 => [ |
|
| 173 | - 'message' => 'Token is not valid', |
|
| 174 | - 'type' => 'error' |
|
| 175 | - ], |
|
| 176 | - |
|
| 177 | - 5445 => [ |
|
| 178 | - 'message' => 'Oops... Database connection refused', |
|
| 179 | - 'type' => 'error' |
|
| 180 | - ], |
|
| 181 | - |
|
| 182 | - 5448 => [ |
|
| 183 | - 'message' => 'Oops... Insert action was not successfully executed', |
|
| 184 | - 'type' => 'error' |
|
| 185 | - ], |
|
| 186 | - |
|
| 187 | - 5447 => [ |
|
| 188 | - 'message' => 'Oops... Delete action was not successfully executed', |
|
| 189 | - 'type' => 'error' |
|
| 190 | - ], |
|
| 191 | - |
|
| 192 | - 5449 => [ |
|
| 193 | - 'message' => 'Oops... Update action was not successfully executed', |
|
| 194 | - 'type' => 'error' |
|
| 195 | - ] |
|
| 5 | + 'success' => [ |
|
| 6 | + |
|
| 7 | + 'insert' => 'The requested parameter is Added successfully!', |
|
| 8 | + |
|
| 9 | + 'delete' => 'The requested parameter is deleted successfully!', |
|
| 10 | + |
|
| 11 | + 'update' => 'The requested parameter is updated successfully!' |
|
| 12 | + |
|
| 13 | + ], |
|
| 14 | + |
|
| 15 | + 'fail' => [ |
|
| 16 | + |
|
| 17 | + 'insert' => 'The requested parameter is not Added!', |
|
| 18 | + |
|
| 19 | + 'delete' => 'The requested parameter is not deleted!', |
|
| 20 | + |
|
| 21 | + 'update' => 'The requested parameter is not updated!' |
|
| 22 | + |
|
| 23 | + ], |
|
| 24 | + |
|
| 25 | + 1001 => [ |
|
| 26 | + 'message' => 'Oops... Requested failed is not found!', |
|
| 27 | + 'type' => 'error' |
|
| 28 | + ], |
|
| 29 | + |
|
| 30 | + 1002 => [ |
|
| 31 | + 'message' => 'Oops... Requested User does not exists!', |
|
| 32 | + 'type' => 'error' |
|
| 33 | + ], |
|
| 34 | + |
|
| 35 | + 1003 => [ |
|
| 36 | + 'message' => 'Oops... Client type is not entered!', |
|
| 37 | + 'type' => 'error' |
|
| 38 | + ], |
|
| 39 | + |
|
| 40 | + 1004 => [ |
|
| 41 | + 'message' => 'Failed because of duplicate', |
|
| 42 | + 'type' => 'error' |
|
| 43 | + ], |
|
| 44 | + |
|
| 45 | + 1005 => [ |
|
| 46 | + 'message' => 'Failed because of dablicated user role', |
|
| 47 | + 'type' => 'error' |
|
| 48 | + ], |
|
| 49 | + |
|
| 50 | + 3001 => [ |
|
| 51 | + 'message' => 'You are not logged on', |
|
| 52 | + 'type' => 'error', |
|
| 53 | + 'cat' => 'auth', |
|
| 54 | + 'short' => 'not-logged-on' |
|
| 55 | + ], |
|
| 56 | + |
|
| 57 | + 3002 => [ |
|
| 58 | + 'message' => 'Application token did not generated successfully', |
|
| 59 | + 'type' => 'error', |
|
| 60 | + 'cat' => 'auth' |
|
| 61 | + ], |
|
| 62 | + |
|
| 63 | + 3003 => [ |
|
| 64 | + 'message' => 'User token did not generated successfully', |
|
| 65 | + 'type' => 'error', |
|
| 66 | + 'cat' => 'auth' |
|
| 67 | + ], |
|
| 68 | + |
|
| 69 | + 3004 => [ |
|
| 70 | + 'message' => 'Request token have no agency access', |
|
| 71 | + 'type' => 'error', |
|
| 72 | + 'cat' => 'auth' |
|
| 73 | + ], |
|
| 74 | + |
|
| 75 | + 3005 => [ |
|
| 76 | + 'message' => 'Request token did not contains user information', |
|
| 77 | + 'type' => 'error', |
|
| 78 | + 'cat' => 'auth' |
|
| 79 | + ], |
|
| 80 | + |
|
| 81 | + 3006 => [ |
|
| 82 | + 'message' => 'Did not set request token', |
|
| 83 | + 'type' => 'error', |
|
| 84 | + 'cat' => 'auth' |
|
| 85 | + ], |
|
| 86 | + |
|
| 87 | + 3007 => [ |
|
| 88 | + 'message' => 'can not decode the token', |
|
| 89 | + 'type' => 'error', |
|
| 90 | + 'cat' => 'auth' |
|
| 91 | + ], |
|
| 92 | + |
|
| 93 | + 3008 => [ |
|
| 94 | + 'message' => 'can not generate token for authentication', |
|
| 95 | + 'type' => 'error', |
|
| 96 | + 'cat' => 'auth' |
|
| 97 | + ], |
|
| 98 | + |
|
| 99 | + 3009 => [ |
|
| 100 | + 'message' => 'can not create token', |
|
| 101 | + 'type' => 'error', |
|
| 102 | + 'cat' => 'auth' |
|
| 103 | + ], |
|
| 104 | + |
|
| 105 | + 3010 => [ |
|
| 106 | + 'message' => 'Token expired!', |
|
| 107 | + 'type' => 'error', |
|
| 108 | + 'cat' => 'auth' |
|
| 109 | + ], |
|
| 110 | + |
|
| 111 | + 3011 => [ |
|
| 112 | + 'message' => 'Token is invalid!', |
|
| 113 | + 'type' => 'error', |
|
| 114 | + 'cat' => 'auth' |
|
| 115 | + ], |
|
| 116 | + |
|
| 117 | + 3012 => [ |
|
| 118 | + 'message' => 'Token Blacklisted', |
|
| 119 | + 'type' => 'error', |
|
| 120 | + 'cat' => 'auth' |
|
| 121 | + ], |
|
| 122 | + |
|
| 123 | + 3013 => [ |
|
| 124 | + 'message' => 'Payload invalid!', |
|
| 125 | + 'type' => 'error', |
|
| 126 | + 'cat' => 'auth' |
|
| 127 | + ], |
|
| 128 | + |
|
| 129 | + 3014 => [ |
|
| 130 | + 'message' => 'Claim Invalid', |
|
| 131 | + 'type' => 'error', |
|
| 132 | + 'cat' => 'auth' |
|
| 133 | + ], |
|
| 134 | + |
|
| 135 | + 3015 => [ |
|
| 136 | + 'message' => 'An error occurred on token validation', |
|
| 137 | + 'type' => 'error', |
|
| 138 | + 'cat' => 'auth' |
|
| 139 | + ], |
|
| 140 | + |
|
| 141 | + 3016 => [ |
|
| 142 | + |
|
| 143 | + 'message' => 'This domain has been blocked', |
|
| 144 | + 'type' => 'error' |
|
| 145 | + ], |
|
| 146 | + |
|
| 147 | + 5401 => [ |
|
| 148 | + 'message' => 'Authentication unauthorized...', |
|
| 149 | + 'type' => 'error' |
|
| 150 | + ], |
|
| 151 | + |
|
| 152 | + 5404 => [ |
|
| 153 | + 'message' => 'Oops... The requested page not found!', |
|
| 154 | + 'type' => 'error' |
|
| 155 | + ], |
|
| 156 | + |
|
| 157 | + 5405 => [ |
|
| 158 | + 'message' => 'Oops... The method you requested is not allowed!', |
|
| 159 | + 'type' => 'error' |
|
| 160 | + ], |
|
| 161 | + |
|
| 162 | + 5406 => [ |
|
| 163 | + 'message' => 'Oops... The parameters you entered are wrong!', |
|
| 164 | + 'type' => 'error' |
|
| 165 | + ], |
|
| 166 | + |
|
| 167 | + 5420 => [ |
|
| 168 | + 'message' => 'Validation Error', |
|
| 169 | + 'type' => 'error' |
|
| 170 | + ], |
|
| 171 | + |
|
| 172 | + 5422 => [ |
|
| 173 | + 'message' => 'Token is not valid', |
|
| 174 | + 'type' => 'error' |
|
| 175 | + ], |
|
| 176 | + |
|
| 177 | + 5445 => [ |
|
| 178 | + 'message' => 'Oops... Database connection refused', |
|
| 179 | + 'type' => 'error' |
|
| 180 | + ], |
|
| 181 | + |
|
| 182 | + 5448 => [ |
|
| 183 | + 'message' => 'Oops... Insert action was not successfully executed', |
|
| 184 | + 'type' => 'error' |
|
| 185 | + ], |
|
| 186 | + |
|
| 187 | + 5447 => [ |
|
| 188 | + 'message' => 'Oops... Delete action was not successfully executed', |
|
| 189 | + 'type' => 'error' |
|
| 190 | + ], |
|
| 191 | + |
|
| 192 | + 5449 => [ |
|
| 193 | + 'message' => 'Oops... Update action was not successfully executed', |
|
| 194 | + 'type' => 'error' |
|
| 195 | + ] |
|
| 196 | 196 | |
| 197 | 197 | ]; |
@@ -2,190 +2,190 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - 'success' => [ |
|
| 6 | - |
|
| 7 | - 'insert' => 'درخواست با موفقیت درج شده است.', |
|
| 8 | - |
|
| 9 | - 'delete' => 'درخواست با موفقیت پاک شده است.', |
|
| 10 | - |
|
| 11 | - 'update' => 'درخواست با موفقیت ویرایش شده است.' |
|
| 12 | - |
|
| 13 | - ], |
|
| 14 | - |
|
| 15 | - 'fail' => [ |
|
| 16 | - |
|
| 17 | - 'insert' => 'درخواست با خطا مواجه شد.', |
|
| 18 | - |
|
| 19 | - 'delete' => 'درخواست حذف با خطا مواجه شد.', |
|
| 20 | - |
|
| 21 | - 'update' => 'درخواست ویرایش با خطا مواجه شد.' |
|
| 22 | - |
|
| 23 | - ], |
|
| 24 | - |
|
| 25 | - 1001 => [ |
|
| 26 | - 'message' => 'درخواست مورد نظر پیدا نشده است.', |
|
| 27 | - 'type' => 'error' |
|
| 28 | - ], |
|
| 29 | - |
|
| 30 | - 1002 => [ |
|
| 31 | - 'message' => 'کاربر مورد نظر موجود نیست.', |
|
| 32 | - 'type' => 'error' |
|
| 33 | - ], |
|
| 34 | - |
|
| 35 | - 1003 => [ |
|
| 36 | - 'message' => 'نوع کاربری وارد نشده است.', |
|
| 37 | - 'type' => 'error' |
|
| 38 | - ], |
|
| 39 | - |
|
| 40 | - 1004 => [ |
|
| 41 | - 'message' => 'ورودی مورد نظر تکراری است.', |
|
| 42 | - 'type' => 'error' |
|
| 43 | - ], |
|
| 44 | - |
|
| 45 | - 1005 => [ |
|
| 46 | - 'message' => 'نقش کاربر مورد نظر تکراری است.', |
|
| 47 | - 'type' => 'error' |
|
| 48 | - ], |
|
| 49 | - |
|
| 50 | - 3001 => [ |
|
| 51 | - 'message' => 'شما به سیستم وارد نشده اید.', |
|
| 52 | - 'type' => 'error', |
|
| 53 | - 'cat' => 'auth', |
|
| 54 | - 'short' => 'not-logged-on' |
|
| 55 | - ], |
|
| 56 | - |
|
| 57 | - 3002 => [ |
|
| 58 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 59 | - 'type' => 'error', |
|
| 60 | - 'cat' => 'auth' |
|
| 61 | - ], |
|
| 62 | - |
|
| 63 | - 3003 => [ |
|
| 64 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 65 | - 'type' => 'error', |
|
| 66 | - 'cat' => 'auth' |
|
| 67 | - ], |
|
| 68 | - |
|
| 69 | - 3004 => [ |
|
| 70 | - 'message' => 'هیچ آژانسی به نشان شناسایی دسترسی ندارد.', |
|
| 71 | - 'type' => 'error', |
|
| 72 | - 'cat' => 'auth' |
|
| 73 | - ], |
|
| 74 | - |
|
| 75 | - 3005 => [ |
|
| 76 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 77 | - 'type' => 'error', |
|
| 78 | - 'cat' => 'auth' |
|
| 79 | - ], |
|
| 80 | - |
|
| 81 | - 3006 => [ |
|
| 82 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 83 | - 'type' => 'error', |
|
| 84 | - 'cat' => 'auth' |
|
| 85 | - ], |
|
| 86 | - |
|
| 87 | - 3007 => [ |
|
| 88 | - 'message' => 'نشان شناسایی شما نمایش داده نمیشود.', |
|
| 89 | - 'type' => 'error', |
|
| 90 | - 'cat' => 'auth' |
|
| 91 | - ], |
|
| 92 | - |
|
| 93 | - 3008 => [ |
|
| 94 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 95 | - 'type' => 'error', |
|
| 96 | - 'cat' => 'auth' |
|
| 97 | - ], |
|
| 98 | - |
|
| 99 | - 3009 => [ |
|
| 100 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 101 | - 'type' => 'error', |
|
| 102 | - 'cat' => 'auth' |
|
| 103 | - ], |
|
| 104 | - |
|
| 105 | - 3010 => [ |
|
| 106 | - 'message' => 'زمان استفاده از نشان شناسایی شما گذشته است.', |
|
| 107 | - 'type' => 'error', |
|
| 108 | - 'cat' => 'auth' |
|
| 109 | - ], |
|
| 110 | - |
|
| 111 | - 3011 => [ |
|
| 112 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 113 | - 'type' => 'error', |
|
| 114 | - 'cat' => 'auth' |
|
| 115 | - ], |
|
| 116 | - |
|
| 117 | - 3012 => [ |
|
| 118 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 119 | - 'type' => 'error', |
|
| 120 | - 'cat' => 'auth' |
|
| 121 | - ], |
|
| 122 | - |
|
| 123 | - 3013 => [ |
|
| 124 | - 'message' => 'Payload معتبر نیست.', |
|
| 125 | - 'type' => 'error', |
|
| 126 | - 'cat' => 'auth' |
|
| 127 | - ], |
|
| 128 | - |
|
| 129 | - 3014 => [ |
|
| 130 | - 'message' => 'Claim معتبر نیست.', |
|
| 131 | - 'type' => 'error', |
|
| 132 | - 'cat' => 'auth' |
|
| 133 | - ], |
|
| 134 | - |
|
| 135 | - 3015 => [ |
|
| 136 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 137 | - 'type' => 'error', |
|
| 138 | - 'cat' => 'auth' |
|
| 139 | - ], |
|
| 140 | - |
|
| 141 | - 5401 => [ |
|
| 142 | - 'message' => 'شناسایی کاربر نامعتبر است.', |
|
| 143 | - 'type' => 'error' |
|
| 144 | - ], |
|
| 145 | - |
|
| 146 | - 5404 => [ |
|
| 147 | - 'message' => 'صفحه درخواست شده پیدا نمیشود.', |
|
| 148 | - 'type' => 'error' |
|
| 149 | - ], |
|
| 150 | - |
|
| 151 | - 5405 => [ |
|
| 152 | - 'message' => 'شما به درخواستی که داده اید دسترسی ندارید.', |
|
| 153 | - 'type' => 'error' |
|
| 154 | - ], |
|
| 155 | - |
|
| 156 | - 5406 => [ |
|
| 157 | - 'message' => 'پارامترهایی که شما وارد کرده اید نا معتبر است.', |
|
| 158 | - 'type' => 'error' |
|
| 159 | - ], |
|
| 160 | - |
|
| 161 | - 5420 => [ |
|
| 162 | - 'message' => 'خطای اعتبار سنجی.', |
|
| 163 | - 'type' => 'error' |
|
| 164 | - ], |
|
| 165 | - |
|
| 166 | - 5422 => [ |
|
| 167 | - 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 168 | - 'type' => 'error' |
|
| 169 | - ], |
|
| 170 | - |
|
| 171 | - 5445 => [ |
|
| 172 | - 'message' => 'ارتباط با پایگاه داده مشکل دارد.', |
|
| 173 | - 'type' => 'error' |
|
| 174 | - ], |
|
| 175 | - |
|
| 176 | - 5448 => [ |
|
| 177 | - 'message' => 'عملیات درج درست اجرا نشده است.', |
|
| 178 | - 'type' => 'error' |
|
| 179 | - ], |
|
| 180 | - |
|
| 181 | - 5447 => [ |
|
| 182 | - 'message' => 'عملیات پاک کردن درست اجرا نشده است.', |
|
| 183 | - 'type' => 'error' |
|
| 184 | - ], |
|
| 185 | - |
|
| 186 | - 5449 => [ |
|
| 187 | - 'message' => 'عملیات ویرایش درست اجرا نشده است.', |
|
| 188 | - 'type' => 'error' |
|
| 189 | - ] |
|
| 5 | + 'success' => [ |
|
| 6 | + |
|
| 7 | + 'insert' => 'درخواست با موفقیت درج شده است.', |
|
| 8 | + |
|
| 9 | + 'delete' => 'درخواست با موفقیت پاک شده است.', |
|
| 10 | + |
|
| 11 | + 'update' => 'درخواست با موفقیت ویرایش شده است.' |
|
| 12 | + |
|
| 13 | + ], |
|
| 14 | + |
|
| 15 | + 'fail' => [ |
|
| 16 | + |
|
| 17 | + 'insert' => 'درخواست با خطا مواجه شد.', |
|
| 18 | + |
|
| 19 | + 'delete' => 'درخواست حذف با خطا مواجه شد.', |
|
| 20 | + |
|
| 21 | + 'update' => 'درخواست ویرایش با خطا مواجه شد.' |
|
| 22 | + |
|
| 23 | + ], |
|
| 24 | + |
|
| 25 | + 1001 => [ |
|
| 26 | + 'message' => 'درخواست مورد نظر پیدا نشده است.', |
|
| 27 | + 'type' => 'error' |
|
| 28 | + ], |
|
| 29 | + |
|
| 30 | + 1002 => [ |
|
| 31 | + 'message' => 'کاربر مورد نظر موجود نیست.', |
|
| 32 | + 'type' => 'error' |
|
| 33 | + ], |
|
| 34 | + |
|
| 35 | + 1003 => [ |
|
| 36 | + 'message' => 'نوع کاربری وارد نشده است.', |
|
| 37 | + 'type' => 'error' |
|
| 38 | + ], |
|
| 39 | + |
|
| 40 | + 1004 => [ |
|
| 41 | + 'message' => 'ورودی مورد نظر تکراری است.', |
|
| 42 | + 'type' => 'error' |
|
| 43 | + ], |
|
| 44 | + |
|
| 45 | + 1005 => [ |
|
| 46 | + 'message' => 'نقش کاربر مورد نظر تکراری است.', |
|
| 47 | + 'type' => 'error' |
|
| 48 | + ], |
|
| 49 | + |
|
| 50 | + 3001 => [ |
|
| 51 | + 'message' => 'شما به سیستم وارد نشده اید.', |
|
| 52 | + 'type' => 'error', |
|
| 53 | + 'cat' => 'auth', |
|
| 54 | + 'short' => 'not-logged-on' |
|
| 55 | + ], |
|
| 56 | + |
|
| 57 | + 3002 => [ |
|
| 58 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 59 | + 'type' => 'error', |
|
| 60 | + 'cat' => 'auth' |
|
| 61 | + ], |
|
| 62 | + |
|
| 63 | + 3003 => [ |
|
| 64 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 65 | + 'type' => 'error', |
|
| 66 | + 'cat' => 'auth' |
|
| 67 | + ], |
|
| 68 | + |
|
| 69 | + 3004 => [ |
|
| 70 | + 'message' => 'هیچ آژانسی به نشان شناسایی دسترسی ندارد.', |
|
| 71 | + 'type' => 'error', |
|
| 72 | + 'cat' => 'auth' |
|
| 73 | + ], |
|
| 74 | + |
|
| 75 | + 3005 => [ |
|
| 76 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 77 | + 'type' => 'error', |
|
| 78 | + 'cat' => 'auth' |
|
| 79 | + ], |
|
| 80 | + |
|
| 81 | + 3006 => [ |
|
| 82 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 83 | + 'type' => 'error', |
|
| 84 | + 'cat' => 'auth' |
|
| 85 | + ], |
|
| 86 | + |
|
| 87 | + 3007 => [ |
|
| 88 | + 'message' => 'نشان شناسایی شما نمایش داده نمیشود.', |
|
| 89 | + 'type' => 'error', |
|
| 90 | + 'cat' => 'auth' |
|
| 91 | + ], |
|
| 92 | + |
|
| 93 | + 3008 => [ |
|
| 94 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 95 | + 'type' => 'error', |
|
| 96 | + 'cat' => 'auth' |
|
| 97 | + ], |
|
| 98 | + |
|
| 99 | + 3009 => [ |
|
| 100 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 101 | + 'type' => 'error', |
|
| 102 | + 'cat' => 'auth' |
|
| 103 | + ], |
|
| 104 | + |
|
| 105 | + 3010 => [ |
|
| 106 | + 'message' => 'زمان استفاده از نشان شناسایی شما گذشته است.', |
|
| 107 | + 'type' => 'error', |
|
| 108 | + 'cat' => 'auth' |
|
| 109 | + ], |
|
| 110 | + |
|
| 111 | + 3011 => [ |
|
| 112 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 113 | + 'type' => 'error', |
|
| 114 | + 'cat' => 'auth' |
|
| 115 | + ], |
|
| 116 | + |
|
| 117 | + 3012 => [ |
|
| 118 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 119 | + 'type' => 'error', |
|
| 120 | + 'cat' => 'auth' |
|
| 121 | + ], |
|
| 122 | + |
|
| 123 | + 3013 => [ |
|
| 124 | + 'message' => 'Payload معتبر نیست.', |
|
| 125 | + 'type' => 'error', |
|
| 126 | + 'cat' => 'auth' |
|
| 127 | + ], |
|
| 128 | + |
|
| 129 | + 3014 => [ |
|
| 130 | + 'message' => 'Claim معتبر نیست.', |
|
| 131 | + 'type' => 'error', |
|
| 132 | + 'cat' => 'auth' |
|
| 133 | + ], |
|
| 134 | + |
|
| 135 | + 3015 => [ |
|
| 136 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 137 | + 'type' => 'error', |
|
| 138 | + 'cat' => 'auth' |
|
| 139 | + ], |
|
| 140 | + |
|
| 141 | + 5401 => [ |
|
| 142 | + 'message' => 'شناسایی کاربر نامعتبر است.', |
|
| 143 | + 'type' => 'error' |
|
| 144 | + ], |
|
| 145 | + |
|
| 146 | + 5404 => [ |
|
| 147 | + 'message' => 'صفحه درخواست شده پیدا نمیشود.', |
|
| 148 | + 'type' => 'error' |
|
| 149 | + ], |
|
| 150 | + |
|
| 151 | + 5405 => [ |
|
| 152 | + 'message' => 'شما به درخواستی که داده اید دسترسی ندارید.', |
|
| 153 | + 'type' => 'error' |
|
| 154 | + ], |
|
| 155 | + |
|
| 156 | + 5406 => [ |
|
| 157 | + 'message' => 'پارامترهایی که شما وارد کرده اید نا معتبر است.', |
|
| 158 | + 'type' => 'error' |
|
| 159 | + ], |
|
| 160 | + |
|
| 161 | + 5420 => [ |
|
| 162 | + 'message' => 'خطای اعتبار سنجی.', |
|
| 163 | + 'type' => 'error' |
|
| 164 | + ], |
|
| 165 | + |
|
| 166 | + 5422 => [ |
|
| 167 | + 'message' => 'نشان شناسایی شما نامعتبر است.', |
|
| 168 | + 'type' => 'error' |
|
| 169 | + ], |
|
| 170 | + |
|
| 171 | + 5445 => [ |
|
| 172 | + 'message' => 'ارتباط با پایگاه داده مشکل دارد.', |
|
| 173 | + 'type' => 'error' |
|
| 174 | + ], |
|
| 175 | + |
|
| 176 | + 5448 => [ |
|
| 177 | + 'message' => 'عملیات درج درست اجرا نشده است.', |
|
| 178 | + 'type' => 'error' |
|
| 179 | + ], |
|
| 180 | + |
|
| 181 | + 5447 => [ |
|
| 182 | + 'message' => 'عملیات پاک کردن درست اجرا نشده است.', |
|
| 183 | + 'type' => 'error' |
|
| 184 | + ], |
|
| 185 | + |
|
| 186 | + 5449 => [ |
|
| 187 | + 'message' => 'عملیات ویرایش درست اجرا نشده است.', |
|
| 188 | + 'type' => 'error' |
|
| 189 | + ] |
|
| 190 | 190 | |
| 191 | 191 | ]; |
@@ -5,290 +5,290 @@ |
||
| 5 | 5 | class Main |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * Http status code |
|
| 10 | - * @var integer |
|
| 11 | - */ |
|
| 12 | - protected $statusCode = 200; |
|
| 13 | - |
|
| 14 | - /** |
|
| 15 | - * Status text |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - protected $statusText = 'success'; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Error code, message and text-key |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - protected $error; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Error code |
|
| 28 | - * @var integer |
|
| 29 | - */ |
|
| 30 | - protected $errorCode; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Haeders |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - protected $headers = []; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - protected $lang; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var array |
|
| 45 | - */ |
|
| 46 | - protected $config; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @author Shahrokh Niakan <[email protected]> |
|
| 50 | - * @since Sep 24, 2016 |
|
| 51 | - */ |
|
| 52 | - public function __construct() |
|
| 53 | - { |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - if (class_exists('\App')) { |
|
| 57 | - $this->lang = \App::getLocale(); |
|
| 58 | - } else { |
|
| 59 | - $this->lang = /** @scrutinizer ignore-call */ |
|
| 60 | - app('translator')->getLocale(); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if (!file_exists(config_path($this->lang . '.php'))) { |
|
| 64 | - $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
| 65 | - } else { |
|
| 66 | - $this->config = include config_path($this->lang . '.php'); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Getter for $statusCode |
|
| 73 | - * @author Shima Payro <[email protected]> |
|
| 74 | - * @since May 2, 2016 9:46:27 AM |
|
| 75 | - * @uses |
|
| 76 | - * @see |
|
| 77 | - */ |
|
| 78 | - public function getStatusCode() |
|
| 79 | - { |
|
| 80 | - |
|
| 81 | - return $this->statusCode; |
|
| 82 | - |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Setter for $statusCode |
|
| 87 | - * @param integer $statusCode |
|
| 88 | - * @return $this |
|
| 89 | - * @author Shima Payro <[email protected]> |
|
| 90 | - * @since May 2, 2016 9:47:04 AM |
|
| 91 | - * @uses |
|
| 92 | - * @see |
|
| 93 | - */ |
|
| 94 | - public function setStatusCode($statusCode) |
|
| 95 | - { |
|
| 96 | - |
|
| 97 | - $this->statusCode = $statusCode; |
|
| 98 | - |
|
| 99 | - return $this; |
|
| 100 | - |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Getter for $statusText |
|
| 105 | - * @author Shima Payro <[email protected]> |
|
| 106 | - * @since May 2, 2016 9:47:36 AM |
|
| 107 | - * @uses |
|
| 108 | - * @see |
|
| 109 | - */ |
|
| 110 | - public function getStatusText() |
|
| 111 | - { |
|
| 112 | - |
|
| 113 | - return $this->statusText; |
|
| 114 | - |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Setter for $statusText |
|
| 119 | - * @param String $statusText |
|
| 120 | - * @return $this |
|
| 121 | - * @author Shima Payro <[email protected]> |
|
| 122 | - * @since May 2, 2016 9:48:23 AM |
|
| 123 | - * @uses |
|
| 124 | - * @see |
|
| 125 | - */ |
|
| 126 | - public function setStatusText($statusText) |
|
| 127 | - { |
|
| 128 | - |
|
| 129 | - $this->statusText = $statusText; |
|
| 130 | - |
|
| 131 | - return $this; |
|
| 132 | - |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Response |
|
| 137 | - * @param $data : json |
|
| 138 | - * @return mixed |
|
| 139 | - * @author Shima Payro <[email protected]> |
|
| 140 | - * @since May 2, 2016 9:48:45 AM |
|
| 141 | - * @uses |
|
| 142 | - * @see |
|
| 143 | - */ |
|
| 144 | - public function respond($data) |
|
| 145 | - { |
|
| 146 | - |
|
| 147 | - $result = array_filter($this->getHeaders()); |
|
| 148 | - |
|
| 149 | - if (empty($result)) |
|
| 150 | - return response()->json($data, $this->getStatusCode()); |
|
| 151 | - |
|
| 152 | - return response()->json($data, $this->getStatusCode()) |
|
| 153 | - ->withHeaders($this->getHeaders()); |
|
| 154 | - |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Response which conteins just a message |
|
| 159 | - * @param string $message |
|
| 160 | - * @return mixed |
|
| 161 | - * @since May 2, 2016 9:49:21 AM |
|
| 162 | - * @author Shima Payro <[email protected]> |
|
| 163 | - * @uses |
|
| 164 | - * @see |
|
| 165 | - */ |
|
| 166 | - public function respondWithMessage($message = null) |
|
| 167 | - { |
|
| 168 | - |
|
| 169 | - $res['status'] = $this->getStatusText(); |
|
| 170 | - |
|
| 171 | - //if it's about failure |
|
| 172 | - if ($this->getErrorCode()) { |
|
| 173 | - |
|
| 174 | - $res['error'] = $this->getErrorCode(); |
|
| 175 | - |
|
| 176 | - if (is_null($message)) |
|
| 177 | - $res['message'] = $this->getErrorMessage(); |
|
| 178 | - else |
|
| 179 | - $res['message'] = $message; |
|
| 8 | + /** |
|
| 9 | + * Http status code |
|
| 10 | + * @var integer |
|
| 11 | + */ |
|
| 12 | + protected $statusCode = 200; |
|
| 13 | + |
|
| 14 | + /** |
|
| 15 | + * Status text |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + protected $statusText = 'success'; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Error code, message and text-key |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + protected $error; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Error code |
|
| 28 | + * @var integer |
|
| 29 | + */ |
|
| 30 | + protected $errorCode; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Haeders |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + protected $headers = []; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + protected $lang; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var array |
|
| 45 | + */ |
|
| 46 | + protected $config; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @author Shahrokh Niakan <[email protected]> |
|
| 50 | + * @since Sep 24, 2016 |
|
| 51 | + */ |
|
| 52 | + public function __construct() |
|
| 53 | + { |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + if (class_exists('\App')) { |
|
| 57 | + $this->lang = \App::getLocale(); |
|
| 58 | + } else { |
|
| 59 | + $this->lang = /** @scrutinizer ignore-call */ |
|
| 60 | + app('translator')->getLocale(); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if (!file_exists(config_path($this->lang . '.php'))) { |
|
| 64 | + $this->config = include __DIR__ . '/../errors/lang/' . $this->lang . '.php'; |
|
| 65 | + } else { |
|
| 66 | + $this->config = include config_path($this->lang . '.php'); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Getter for $statusCode |
|
| 73 | + * @author Shima Payro <[email protected]> |
|
| 74 | + * @since May 2, 2016 9:46:27 AM |
|
| 75 | + * @uses |
|
| 76 | + * @see |
|
| 77 | + */ |
|
| 78 | + public function getStatusCode() |
|
| 79 | + { |
|
| 80 | + |
|
| 81 | + return $this->statusCode; |
|
| 82 | + |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Setter for $statusCode |
|
| 87 | + * @param integer $statusCode |
|
| 88 | + * @return $this |
|
| 89 | + * @author Shima Payro <[email protected]> |
|
| 90 | + * @since May 2, 2016 9:47:04 AM |
|
| 91 | + * @uses |
|
| 92 | + * @see |
|
| 93 | + */ |
|
| 94 | + public function setStatusCode($statusCode) |
|
| 95 | + { |
|
| 96 | + |
|
| 97 | + $this->statusCode = $statusCode; |
|
| 98 | + |
|
| 99 | + return $this; |
|
| 100 | + |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Getter for $statusText |
|
| 105 | + * @author Shima Payro <[email protected]> |
|
| 106 | + * @since May 2, 2016 9:47:36 AM |
|
| 107 | + * @uses |
|
| 108 | + * @see |
|
| 109 | + */ |
|
| 110 | + public function getStatusText() |
|
| 111 | + { |
|
| 112 | + |
|
| 113 | + return $this->statusText; |
|
| 114 | + |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Setter for $statusText |
|
| 119 | + * @param String $statusText |
|
| 120 | + * @return $this |
|
| 121 | + * @author Shima Payro <[email protected]> |
|
| 122 | + * @since May 2, 2016 9:48:23 AM |
|
| 123 | + * @uses |
|
| 124 | + * @see |
|
| 125 | + */ |
|
| 126 | + public function setStatusText($statusText) |
|
| 127 | + { |
|
| 128 | + |
|
| 129 | + $this->statusText = $statusText; |
|
| 130 | + |
|
| 131 | + return $this; |
|
| 132 | + |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Response |
|
| 137 | + * @param $data : json |
|
| 138 | + * @return mixed |
|
| 139 | + * @author Shima Payro <[email protected]> |
|
| 140 | + * @since May 2, 2016 9:48:45 AM |
|
| 141 | + * @uses |
|
| 142 | + * @see |
|
| 143 | + */ |
|
| 144 | + public function respond($data) |
|
| 145 | + { |
|
| 146 | + |
|
| 147 | + $result = array_filter($this->getHeaders()); |
|
| 148 | + |
|
| 149 | + if (empty($result)) |
|
| 150 | + return response()->json($data, $this->getStatusCode()); |
|
| 151 | + |
|
| 152 | + return response()->json($data, $this->getStatusCode()) |
|
| 153 | + ->withHeaders($this->getHeaders()); |
|
| 154 | + |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Response which conteins just a message |
|
| 159 | + * @param string $message |
|
| 160 | + * @return mixed |
|
| 161 | + * @since May 2, 2016 9:49:21 AM |
|
| 162 | + * @author Shima Payro <[email protected]> |
|
| 163 | + * @uses |
|
| 164 | + * @see |
|
| 165 | + */ |
|
| 166 | + public function respondWithMessage($message = null) |
|
| 167 | + { |
|
| 168 | + |
|
| 169 | + $res['status'] = $this->getStatusText(); |
|
| 170 | + |
|
| 171 | + //if it's about failure |
|
| 172 | + if ($this->getErrorCode()) { |
|
| 173 | + |
|
| 174 | + $res['error'] = $this->getErrorCode(); |
|
| 175 | + |
|
| 176 | + if (is_null($message)) |
|
| 177 | + $res['message'] = $this->getErrorMessage(); |
|
| 178 | + else |
|
| 179 | + $res['message'] = $message; |
|
| 180 | 180 | |
| 181 | - } else { |
|
| 182 | - |
|
| 183 | - $res['message'] = $message; |
|
| 184 | - |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - return $this->respond($res); |
|
| 181 | + } else { |
|
| 182 | + |
|
| 183 | + $res['message'] = $message; |
|
| 184 | + |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + return $this->respond($res); |
|
| 188 | 188 | |
| 189 | - } |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Set error code in our result |
|
| 193 | - * @param $errorCode integer |
|
| 194 | - * @return $this |
|
| 195 | - * @author Mehdi Hosseini <[email protected]> |
|
| 196 | - * @since August 24, 2016 |
|
| 197 | - */ |
|
| 198 | - public function setErrorCode($errorCode) |
|
| 199 | - { |
|
| 191 | + /** |
|
| 192 | + * Set error code in our result |
|
| 193 | + * @param $errorCode integer |
|
| 194 | + * @return $this |
|
| 195 | + * @author Mehdi Hosseini <[email protected]> |
|
| 196 | + * @since August 24, 2016 |
|
| 197 | + */ |
|
| 198 | + public function setErrorCode($errorCode) |
|
| 199 | + { |
|
| 200 | 200 | |
| 201 | - $this->error = $this->config[$errorCode]; |
|
| 201 | + $this->error = $this->config[$errorCode]; |
|
| 202 | 202 | |
| 203 | - $this->errorCode = $errorCode; |
|
| 203 | + $this->errorCode = $errorCode; |
|
| 204 | 204 | |
| 205 | - return $this; |
|
| 205 | + return $this; |
|
| 206 | 206 | |
| 207 | - } |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * Return Error code |
|
| 211 | - * @return integer |
|
| 212 | - * @since August 24, 2016 |
|
| 213 | - * @author Mehdi Hosseini <[email protected]> |
|
| 214 | - */ |
|
| 215 | - public function getErrorCode() |
|
| 216 | - { |
|
| 209 | + /** |
|
| 210 | + * Return Error code |
|
| 211 | + * @return integer |
|
| 212 | + * @since August 24, 2016 |
|
| 213 | + * @author Mehdi Hosseini <[email protected]> |
|
| 214 | + */ |
|
| 215 | + public function getErrorCode() |
|
| 216 | + { |
|
| 217 | 217 | |
| 218 | - return $this->errorCode; |
|
| 218 | + return $this->errorCode; |
|
| 219 | 219 | |
| 220 | - } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * Get error message |
|
| 224 | - * @return string |
|
| 225 | - * @since August 24, 2016 |
|
| 226 | - * @author Mehdi Hosseini <[email protected]> |
|
| 227 | - */ |
|
| 228 | - public function getErrorMessage() |
|
| 229 | - { |
|
| 222 | + /** |
|
| 223 | + * Get error message |
|
| 224 | + * @return string |
|
| 225 | + * @since August 24, 2016 |
|
| 226 | + * @author Mehdi Hosseini <[email protected]> |
|
| 227 | + */ |
|
| 228 | + public function getErrorMessage() |
|
| 229 | + { |
|
| 230 | 230 | |
| 231 | - return $this->error['message']; |
|
| 231 | + return $this->error['message']; |
|
| 232 | 232 | |
| 233 | - } |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - /** |
|
| 236 | - * Get headers |
|
| 237 | - * @return array |
|
| 238 | - * @since Sep 13, 2016 |
|
| 239 | - * @author Shima Payro <[email protected]> |
|
| 240 | - */ |
|
| 241 | - public function getHeaders() |
|
| 242 | - { |
|
| 235 | + /** |
|
| 236 | + * Get headers |
|
| 237 | + * @return array |
|
| 238 | + * @since Sep 13, 2016 |
|
| 239 | + * @author Shima Payro <[email protected]> |
|
| 240 | + */ |
|
| 241 | + public function getHeaders() |
|
| 242 | + { |
|
| 243 | 243 | |
| 244 | - return $this->headers; |
|
| 244 | + return $this->headers; |
|
| 245 | 245 | |
| 246 | - } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - /** |
|
| 249 | - * Set headers |
|
| 250 | - * @param array $headers |
|
| 251 | - * @return $this |
|
| 252 | - * @since Sep 13, 2016 |
|
| 253 | - * @author Shima Payro <[email protected]> |
|
| 254 | - */ |
|
| 255 | - public function setHeaders($headers = []) |
|
| 256 | - { |
|
| 248 | + /** |
|
| 249 | + * Set headers |
|
| 250 | + * @param array $headers |
|
| 251 | + * @return $this |
|
| 252 | + * @since Sep 13, 2016 |
|
| 253 | + * @author Shima Payro <[email protected]> |
|
| 254 | + */ |
|
| 255 | + public function setHeaders($headers = []) |
|
| 256 | + { |
|
| 257 | 257 | |
| 258 | - $this->headers = $headers; |
|
| 258 | + $this->headers = $headers; |
|
| 259 | 259 | |
| 260 | - return $this; |
|
| 260 | + return $this; |
|
| 261 | 261 | |
| 262 | - } |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - /** |
|
| 265 | - * Response which contains status and data |
|
| 266 | - * @param null|array $data |
|
| 267 | - * @return mixed |
|
| 268 | - * @since May 2, 2016 9:50:19 AM |
|
| 269 | - * @author Shima Payro <[email protected]> |
|
| 270 | - * @uses |
|
| 271 | - * @see |
|
| 272 | - */ |
|
| 273 | - public function respondWithResult($data = NULL) |
|
| 274 | - { |
|
| 264 | + /** |
|
| 265 | + * Response which contains status and data |
|
| 266 | + * @param null|array $data |
|
| 267 | + * @return mixed |
|
| 268 | + * @since May 2, 2016 9:50:19 AM |
|
| 269 | + * @author Shima Payro <[email protected]> |
|
| 270 | + * @uses |
|
| 271 | + * @see |
|
| 272 | + */ |
|
| 273 | + public function respondWithResult($data = NULL) |
|
| 274 | + { |
|
| 275 | 275 | |
| 276 | - $res['status'] = $this->getStatusText(); |
|
| 276 | + $res['status'] = $this->getStatusText(); |
|
| 277 | 277 | |
| 278 | - //if it's about laravel validation error |
|
| 279 | - if ($this->getErrorCode() && $this->getStatusCode() == 420) { |
|
| 278 | + //if it's about laravel validation error |
|
| 279 | + if ($this->getErrorCode() && $this->getStatusCode() == 420) { |
|
| 280 | 280 | |
| 281 | - $res['error'] = $this->getErrorCode(); |
|
| 282 | - $res['message'] = $data; |
|
| 281 | + $res['error'] = $this->getErrorCode(); |
|
| 282 | + $res['message'] = $data; |
|
| 283 | 283 | |
| 284 | - } else { |
|
| 284 | + } else { |
|
| 285 | 285 | |
| 286 | - $res['result'] = $data; |
|
| 286 | + $res['result'] = $data; |
|
| 287 | 287 | |
| 288 | - } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - return $this->respond($res); |
|
| 290 | + return $this->respond($res); |
|
| 291 | 291 | |
| 292 | - } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | 294 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * Haeders |
| 34 | 34 | * @var array |
| 35 | 35 | */ |
| 36 | - protected $headers = []; |
|
| 36 | + protected $headers = [ ]; |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * @var string |
@@ -166,21 +166,21 @@ discard block |
||
| 166 | 166 | public function respondWithMessage($message = null) |
| 167 | 167 | { |
| 168 | 168 | |
| 169 | - $res['status'] = $this->getStatusText(); |
|
| 169 | + $res[ 'status' ] = $this->getStatusText(); |
|
| 170 | 170 | |
| 171 | 171 | //if it's about failure |
| 172 | 172 | if ($this->getErrorCode()) { |
| 173 | 173 | |
| 174 | - $res['error'] = $this->getErrorCode(); |
|
| 174 | + $res[ 'error' ] = $this->getErrorCode(); |
|
| 175 | 175 | |
| 176 | 176 | if (is_null($message)) |
| 177 | - $res['message'] = $this->getErrorMessage(); |
|
| 177 | + $res[ 'message' ] = $this->getErrorMessage(); |
|
| 178 | 178 | else |
| 179 | - $res['message'] = $message; |
|
| 179 | + $res[ 'message' ] = $message; |
|
| 180 | 180 | |
| 181 | 181 | } else { |
| 182 | 182 | |
| 183 | - $res['message'] = $message; |
|
| 183 | + $res[ 'message' ] = $message; |
|
| 184 | 184 | |
| 185 | 185 | } |
| 186 | 186 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | public function setErrorCode($errorCode) |
| 199 | 199 | { |
| 200 | 200 | |
| 201 | - $this->error = $this->config[$errorCode]; |
|
| 201 | + $this->error = $this->config[ $errorCode ]; |
|
| 202 | 202 | |
| 203 | 203 | $this->errorCode = $errorCode; |
| 204 | 204 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | public function getErrorMessage() |
| 229 | 229 | { |
| 230 | 230 | |
| 231 | - return $this->error['message']; |
|
| 231 | + return $this->error[ 'message' ]; |
|
| 232 | 232 | |
| 233 | 233 | } |
| 234 | 234 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @since Sep 13, 2016 |
| 253 | 253 | * @author Shima Payro <[email protected]> |
| 254 | 254 | */ |
| 255 | - public function setHeaders($headers = []) |
|
| 255 | + public function setHeaders($headers = [ ]) |
|
| 256 | 256 | { |
| 257 | 257 | |
| 258 | 258 | $this->headers = $headers; |
@@ -273,17 +273,17 @@ discard block |
||
| 273 | 273 | public function respondWithResult($data = NULL) |
| 274 | 274 | { |
| 275 | 275 | |
| 276 | - $res['status'] = $this->getStatusText(); |
|
| 276 | + $res[ 'status' ] = $this->getStatusText(); |
|
| 277 | 277 | |
| 278 | 278 | //if it's about laravel validation error |
| 279 | 279 | if ($this->getErrorCode() && $this->getStatusCode() == 420) { |
| 280 | 280 | |
| 281 | - $res['error'] = $this->getErrorCode(); |
|
| 282 | - $res['message'] = $data; |
|
| 281 | + $res[ 'error' ] = $this->getErrorCode(); |
|
| 282 | + $res[ 'message' ] = $data; |
|
| 283 | 283 | |
| 284 | 284 | } else { |
| 285 | 285 | |
| 286 | - $res['result'] = $data; |
|
| 286 | + $res[ 'result' ] = $data; |
|
| 287 | 287 | |
| 288 | 288 | } |
| 289 | 289 | |
@@ -146,8 +146,9 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $result = array_filter($this->getHeaders()); |
| 148 | 148 | |
| 149 | - if (empty($result)) |
|
| 150 | - return response()->json($data, $this->getStatusCode()); |
|
| 149 | + if (empty($result)) { |
|
| 150 | + return response()->json($data, $this->getStatusCode()); |
|
| 151 | + } |
|
| 151 | 152 | |
| 152 | 153 | return response()->json($data, $this->getStatusCode()) |
| 153 | 154 | ->withHeaders($this->getHeaders()); |
@@ -173,10 +174,11 @@ discard block |
||
| 173 | 174 | |
| 174 | 175 | $res['error'] = $this->getErrorCode(); |
| 175 | 176 | |
| 176 | - if (is_null($message)) |
|
| 177 | - $res['message'] = $this->getErrorMessage(); |
|
| 178 | - else |
|
| 179 | - $res['message'] = $message; |
|
| 177 | + if (is_null($message)) { |
|
| 178 | + $res['message'] = $this->getErrorMessage(); |
|
| 179 | + } else { |
|
| 180 | + $res['message'] = $message; |
|
| 181 | + } |
|
| 180 | 182 | |
| 181 | 183 | } else { |
| 182 | 184 | |
@@ -5,294 +5,294 @@ |
||
| 5 | 5 | class Messages extends Main |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * Request succeeded and contains json result |
|
| 10 | - * @param array $data |
|
| 11 | - * @return mixed |
|
| 12 | - * @since May 2, 2016 9:50:51 AM |
|
| 13 | - * @uses |
|
| 14 | - * @see |
|
| 15 | - * @author Shima Payro <[email protected]> |
|
| 16 | - */ |
|
| 17 | - public function succeed($data) |
|
| 18 | - { |
|
| 19 | - |
|
| 20 | - return $this->setStatusCode(200) |
|
| 21 | - ->setStatusText('success') |
|
| 22 | - ->respondWithResult($data); |
|
| 23 | - |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Delete action is succeed |
|
| 28 | - * @param String $message |
|
| 29 | - * @return mixed |
|
| 30 | - * @since May 2, 2016 9:52:05 AM |
|
| 31 | - * @uses |
|
| 32 | - * @see |
|
| 33 | - * @author Shima Payro <[email protected]> |
|
| 34 | - */ |
|
| 35 | - public function deleteSucceeded($message = null) |
|
| 36 | - { |
|
| 37 | - |
|
| 38 | - if (is_null($message)) |
|
| 39 | - $message = $this->config['success']['delete']; |
|
| 40 | - |
|
| 41 | - return $this->setStatusCode(200) |
|
| 42 | - ->setStatusText('success') |
|
| 43 | - ->respondWithMessage($message); |
|
| 44 | - |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Update action is succeed |
|
| 49 | - * @param String $message |
|
| 50 | - * @return mixed |
|
| 51 | - * @since May 2, 2016 9:52:52 AM |
|
| 52 | - * @uses |
|
| 53 | - * @see |
|
| 54 | - * @author Shima Payro <[email protected]> |
|
| 55 | - */ |
|
| 56 | - public function updateSucceeded($message = null) |
|
| 57 | - { |
|
| 58 | - |
|
| 59 | - if (is_null($message)) |
|
| 60 | - $message = $this->config['success']['update']; |
|
| 61 | - |
|
| 62 | - return $this->setStatusCode(200) |
|
| 63 | - ->setStatusText('success') |
|
| 64 | - ->respondWithMessage($message); |
|
| 65 | - |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Insert action is succeed |
|
| 70 | - * @param String $message |
|
| 71 | - * @return mixed |
|
| 72 | - * @since May 2, 2016 9:53:26 AM |
|
| 73 | - * @uses |
|
| 74 | - * @see |
|
| 75 | - * @author Shima Payro <[email protected]> |
|
| 76 | - */ |
|
| 77 | - public function insertSucceeded($message = null) |
|
| 78 | - { |
|
| 79 | - |
|
| 80 | - if (is_null($message)) |
|
| 81 | - $message = $this->config['success']['insert']; |
|
| 82 | - |
|
| 83 | - return $this->setStatusCode(200) |
|
| 84 | - ->setStatusText('success') |
|
| 85 | - ->respondWithMessage($message); |
|
| 86 | - |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Delete action is failed |
|
| 91 | - * @param String $message |
|
| 92 | - * @return mixed |
|
| 93 | - * @since May 2, 2016 9:53:53 AM |
|
| 94 | - * @uses |
|
| 95 | - * @see |
|
| 96 | - * @author Shima Payro <[email protected]> |
|
| 97 | - */ |
|
| 98 | - public function deleteFailed($message = null) |
|
| 99 | - { |
|
| 100 | - |
|
| 101 | - if (is_null($message)) |
|
| 102 | - $message = $this->config['fail']['delete']; |
|
| 103 | - |
|
| 104 | - return $this->setStatusCode(447) |
|
| 105 | - ->setStatusText('fail') |
|
| 106 | - ->setErrorCode(5447) |
|
| 107 | - ->respondWithMessage($message); |
|
| 108 | - |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Update action is succeed |
|
| 113 | - * @param String $message |
|
| 114 | - * @return mixed |
|
| 115 | - * @since May 2, 2016 9:54:09 AM |
|
| 116 | - * @uses |
|
| 117 | - * @see |
|
| 118 | - * @author Shima Payro <[email protected]> |
|
| 119 | - */ |
|
| 120 | - public function updateFailed($message = null) |
|
| 121 | - { |
|
| 122 | - |
|
| 123 | - if (is_null($message)) |
|
| 124 | - $message = $this->config['fail']['update']; |
|
| 125 | - |
|
| 126 | - return $this->setStatusCode(449) |
|
| 127 | - ->setStatusText('fail') |
|
| 128 | - ->setErrorCode(5449) |
|
| 129 | - ->respondWithMessage($message); |
|
| 130 | - |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Insert action is failed |
|
| 135 | - * @param String $message |
|
| 136 | - * @return mixed |
|
| 137 | - * @since May 2, 2016 9:54:27 AM |
|
| 138 | - * @uses |
|
| 139 | - * @see |
|
| 140 | - * @author Shima Payro <[email protected]> |
|
| 141 | - */ |
|
| 142 | - public function insertFailed($message = null) |
|
| 143 | - { |
|
| 144 | - |
|
| 145 | - if (is_null($message)) |
|
| 146 | - $message = $this->config['fail']['insert']; |
|
| 147 | - |
|
| 148 | - return $this->setStatusCode(448) |
|
| 149 | - ->setStatusText('fail') |
|
| 150 | - ->setErrorCode(5448) |
|
| 151 | - ->respondWithMessage($message); |
|
| 152 | - |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Database connection is refused |
|
| 157 | - * @return mixed |
|
| 158 | - * @since May 2, 2016 9:54:45 AM |
|
| 159 | - * @uses |
|
| 160 | - * @see |
|
| 161 | - * @author Shima Payro <[email protected]> |
|
| 162 | - */ |
|
| 163 | - public function connectionRefused() |
|
| 164 | - { |
|
| 165 | - |
|
| 166 | - return $this->setStatusCode(445) |
|
| 167 | - ->setStatusText('fail') |
|
| 168 | - ->setErrorCode(5445) |
|
| 169 | - ->respondWithMessage(); |
|
| 170 | - |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * page requested is not found |
|
| 175 | - * @return mixed |
|
| 176 | - * @since May 2, 2016 9:55:20 AM |
|
| 177 | - * @uses |
|
| 178 | - * @see |
|
| 179 | - * @author Shima Payro <[email protected]> |
|
| 180 | - */ |
|
| 181 | - public function notFound() |
|
| 182 | - { |
|
| 183 | - |
|
| 184 | - return $this->setStatusCode(404) |
|
| 185 | - ->setStatusText('fail') |
|
| 186 | - ->setErrorCode(5404) |
|
| 187 | - ->respondWithMessage(); |
|
| 188 | - |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Wrong parameters are entered |
|
| 193 | - * @return mixed |
|
| 194 | - * @since May 2, 2016 9:55:20 AM |
|
| 195 | - * @uses |
|
| 196 | - * @see |
|
| 197 | - * @author Shima Payro <[email protected]> |
|
| 198 | - */ |
|
| 199 | - public function wrongParameters() |
|
| 200 | - { |
|
| 201 | - |
|
| 202 | - return $this->setStatusCode(406) |
|
| 203 | - ->setStatusText('fail') |
|
| 204 | - ->setErrorCode(5406) |
|
| 205 | - ->respondWithMessage(); |
|
| 206 | - |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Method is not allowed |
|
| 211 | - * @return mixed |
|
| 212 | - * @since May 2, 2016 9:55:20 AM |
|
| 213 | - * @uses |
|
| 214 | - * @see |
|
| 215 | - * @author Shima Payro <[email protected]> |
|
| 216 | - */ |
|
| 217 | - public function methodNotAllowed() |
|
| 218 | - { |
|
| 219 | - |
|
| 220 | - return $this->setStatusCode(405) |
|
| 221 | - ->setStatusText('fail') |
|
| 222 | - ->setErrorCode(5405) |
|
| 223 | - ->respondWithMessage(); |
|
| 224 | - |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * There ara validation errors |
|
| 229 | - * @param $message string |
|
| 230 | - * @return mixed |
|
| 231 | - * @since May 2, 2016 9:55:20 AM |
|
| 232 | - * @uses |
|
| 233 | - * @see |
|
| 234 | - * @author Shima Payro <[email protected]> |
|
| 235 | - */ |
|
| 236 | - public function validationErrors($message = null) |
|
| 237 | - { |
|
| 238 | - |
|
| 239 | - return $this->setStatusCode(420) |
|
| 240 | - ->setStatusText('fail') |
|
| 241 | - ->setErrorCode(5420) |
|
| 242 | - ->respondWithResult($message); |
|
| 243 | - |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * The request failed is not found |
|
| 248 | - * @return mixed |
|
| 249 | - * @since May 2, 2016 9:55:20 AM |
|
| 250 | - * @uses |
|
| 251 | - * @see |
|
| 252 | - * @author Shima Payro <[email protected]> |
|
| 253 | - */ |
|
| 254 | - public function requestFailedNotFound() |
|
| 255 | - { |
|
| 256 | - |
|
| 257 | - return $this->setStatusCode(446) |
|
| 258 | - ->setStatusText('fail') |
|
| 259 | - ->setErrorCode(1001) |
|
| 260 | - ->respondWithMessage(); |
|
| 261 | - |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * The request failed is doublicated |
|
| 266 | - * @return mixed |
|
| 267 | - * @since August 24, 2016 |
|
| 268 | - * @author Mehdi Hosseini <[email protected]> |
|
| 269 | - */ |
|
| 270 | - public function requestFailedDuplicated() |
|
| 271 | - { |
|
| 272 | - |
|
| 273 | - return $this->setStatusCode(400) |
|
| 274 | - ->setStatusText('fail') |
|
| 275 | - ->SetErrorCode(1004) |
|
| 276 | - ->respondWithMessage(); |
|
| 277 | - |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * Custom error message according to error config file |
|
| 282 | - * @param $code integer |
|
| 283 | - * @return mixed |
|
| 284 | - * @author Mehdi Hosseini <[email protected]> |
|
| 285 | - * @since August 24, 2016 |
|
| 286 | - */ |
|
| 287 | - public function error($code) |
|
| 288 | - { |
|
| 289 | - |
|
| 290 | - return $this->setStatusCode(400) |
|
| 291 | - ->setStatusText('fail') |
|
| 292 | - ->setErrorCode($code) |
|
| 293 | - ->respondWithMessage(); |
|
| 294 | - |
|
| 295 | - } |
|
| 8 | + /** |
|
| 9 | + * Request succeeded and contains json result |
|
| 10 | + * @param array $data |
|
| 11 | + * @return mixed |
|
| 12 | + * @since May 2, 2016 9:50:51 AM |
|
| 13 | + * @uses |
|
| 14 | + * @see |
|
| 15 | + * @author Shima Payro <[email protected]> |
|
| 16 | + */ |
|
| 17 | + public function succeed($data) |
|
| 18 | + { |
|
| 19 | + |
|
| 20 | + return $this->setStatusCode(200) |
|
| 21 | + ->setStatusText('success') |
|
| 22 | + ->respondWithResult($data); |
|
| 23 | + |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Delete action is succeed |
|
| 28 | + * @param String $message |
|
| 29 | + * @return mixed |
|
| 30 | + * @since May 2, 2016 9:52:05 AM |
|
| 31 | + * @uses |
|
| 32 | + * @see |
|
| 33 | + * @author Shima Payro <[email protected]> |
|
| 34 | + */ |
|
| 35 | + public function deleteSucceeded($message = null) |
|
| 36 | + { |
|
| 37 | + |
|
| 38 | + if (is_null($message)) |
|
| 39 | + $message = $this->config['success']['delete']; |
|
| 40 | + |
|
| 41 | + return $this->setStatusCode(200) |
|
| 42 | + ->setStatusText('success') |
|
| 43 | + ->respondWithMessage($message); |
|
| 44 | + |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Update action is succeed |
|
| 49 | + * @param String $message |
|
| 50 | + * @return mixed |
|
| 51 | + * @since May 2, 2016 9:52:52 AM |
|
| 52 | + * @uses |
|
| 53 | + * @see |
|
| 54 | + * @author Shima Payro <[email protected]> |
|
| 55 | + */ |
|
| 56 | + public function updateSucceeded($message = null) |
|
| 57 | + { |
|
| 58 | + |
|
| 59 | + if (is_null($message)) |
|
| 60 | + $message = $this->config['success']['update']; |
|
| 61 | + |
|
| 62 | + return $this->setStatusCode(200) |
|
| 63 | + ->setStatusText('success') |
|
| 64 | + ->respondWithMessage($message); |
|
| 65 | + |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Insert action is succeed |
|
| 70 | + * @param String $message |
|
| 71 | + * @return mixed |
|
| 72 | + * @since May 2, 2016 9:53:26 AM |
|
| 73 | + * @uses |
|
| 74 | + * @see |
|
| 75 | + * @author Shima Payro <[email protected]> |
|
| 76 | + */ |
|
| 77 | + public function insertSucceeded($message = null) |
|
| 78 | + { |
|
| 79 | + |
|
| 80 | + if (is_null($message)) |
|
| 81 | + $message = $this->config['success']['insert']; |
|
| 82 | + |
|
| 83 | + return $this->setStatusCode(200) |
|
| 84 | + ->setStatusText('success') |
|
| 85 | + ->respondWithMessage($message); |
|
| 86 | + |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Delete action is failed |
|
| 91 | + * @param String $message |
|
| 92 | + * @return mixed |
|
| 93 | + * @since May 2, 2016 9:53:53 AM |
|
| 94 | + * @uses |
|
| 95 | + * @see |
|
| 96 | + * @author Shima Payro <[email protected]> |
|
| 97 | + */ |
|
| 98 | + public function deleteFailed($message = null) |
|
| 99 | + { |
|
| 100 | + |
|
| 101 | + if (is_null($message)) |
|
| 102 | + $message = $this->config['fail']['delete']; |
|
| 103 | + |
|
| 104 | + return $this->setStatusCode(447) |
|
| 105 | + ->setStatusText('fail') |
|
| 106 | + ->setErrorCode(5447) |
|
| 107 | + ->respondWithMessage($message); |
|
| 108 | + |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Update action is succeed |
|
| 113 | + * @param String $message |
|
| 114 | + * @return mixed |
|
| 115 | + * @since May 2, 2016 9:54:09 AM |
|
| 116 | + * @uses |
|
| 117 | + * @see |
|
| 118 | + * @author Shima Payro <[email protected]> |
|
| 119 | + */ |
|
| 120 | + public function updateFailed($message = null) |
|
| 121 | + { |
|
| 122 | + |
|
| 123 | + if (is_null($message)) |
|
| 124 | + $message = $this->config['fail']['update']; |
|
| 125 | + |
|
| 126 | + return $this->setStatusCode(449) |
|
| 127 | + ->setStatusText('fail') |
|
| 128 | + ->setErrorCode(5449) |
|
| 129 | + ->respondWithMessage($message); |
|
| 130 | + |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Insert action is failed |
|
| 135 | + * @param String $message |
|
| 136 | + * @return mixed |
|
| 137 | + * @since May 2, 2016 9:54:27 AM |
|
| 138 | + * @uses |
|
| 139 | + * @see |
|
| 140 | + * @author Shima Payro <[email protected]> |
|
| 141 | + */ |
|
| 142 | + public function insertFailed($message = null) |
|
| 143 | + { |
|
| 144 | + |
|
| 145 | + if (is_null($message)) |
|
| 146 | + $message = $this->config['fail']['insert']; |
|
| 147 | + |
|
| 148 | + return $this->setStatusCode(448) |
|
| 149 | + ->setStatusText('fail') |
|
| 150 | + ->setErrorCode(5448) |
|
| 151 | + ->respondWithMessage($message); |
|
| 152 | + |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Database connection is refused |
|
| 157 | + * @return mixed |
|
| 158 | + * @since May 2, 2016 9:54:45 AM |
|
| 159 | + * @uses |
|
| 160 | + * @see |
|
| 161 | + * @author Shima Payro <[email protected]> |
|
| 162 | + */ |
|
| 163 | + public function connectionRefused() |
|
| 164 | + { |
|
| 165 | + |
|
| 166 | + return $this->setStatusCode(445) |
|
| 167 | + ->setStatusText('fail') |
|
| 168 | + ->setErrorCode(5445) |
|
| 169 | + ->respondWithMessage(); |
|
| 170 | + |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * page requested is not found |
|
| 175 | + * @return mixed |
|
| 176 | + * @since May 2, 2016 9:55:20 AM |
|
| 177 | + * @uses |
|
| 178 | + * @see |
|
| 179 | + * @author Shima Payro <[email protected]> |
|
| 180 | + */ |
|
| 181 | + public function notFound() |
|
| 182 | + { |
|
| 183 | + |
|
| 184 | + return $this->setStatusCode(404) |
|
| 185 | + ->setStatusText('fail') |
|
| 186 | + ->setErrorCode(5404) |
|
| 187 | + ->respondWithMessage(); |
|
| 188 | + |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Wrong parameters are entered |
|
| 193 | + * @return mixed |
|
| 194 | + * @since May 2, 2016 9:55:20 AM |
|
| 195 | + * @uses |
|
| 196 | + * @see |
|
| 197 | + * @author Shima Payro <[email protected]> |
|
| 198 | + */ |
|
| 199 | + public function wrongParameters() |
|
| 200 | + { |
|
| 201 | + |
|
| 202 | + return $this->setStatusCode(406) |
|
| 203 | + ->setStatusText('fail') |
|
| 204 | + ->setErrorCode(5406) |
|
| 205 | + ->respondWithMessage(); |
|
| 206 | + |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Method is not allowed |
|
| 211 | + * @return mixed |
|
| 212 | + * @since May 2, 2016 9:55:20 AM |
|
| 213 | + * @uses |
|
| 214 | + * @see |
|
| 215 | + * @author Shima Payro <[email protected]> |
|
| 216 | + */ |
|
| 217 | + public function methodNotAllowed() |
|
| 218 | + { |
|
| 219 | + |
|
| 220 | + return $this->setStatusCode(405) |
|
| 221 | + ->setStatusText('fail') |
|
| 222 | + ->setErrorCode(5405) |
|
| 223 | + ->respondWithMessage(); |
|
| 224 | + |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * There ara validation errors |
|
| 229 | + * @param $message string |
|
| 230 | + * @return mixed |
|
| 231 | + * @since May 2, 2016 9:55:20 AM |
|
| 232 | + * @uses |
|
| 233 | + * @see |
|
| 234 | + * @author Shima Payro <[email protected]> |
|
| 235 | + */ |
|
| 236 | + public function validationErrors($message = null) |
|
| 237 | + { |
|
| 238 | + |
|
| 239 | + return $this->setStatusCode(420) |
|
| 240 | + ->setStatusText('fail') |
|
| 241 | + ->setErrorCode(5420) |
|
| 242 | + ->respondWithResult($message); |
|
| 243 | + |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * The request failed is not found |
|
| 248 | + * @return mixed |
|
| 249 | + * @since May 2, 2016 9:55:20 AM |
|
| 250 | + * @uses |
|
| 251 | + * @see |
|
| 252 | + * @author Shima Payro <[email protected]> |
|
| 253 | + */ |
|
| 254 | + public function requestFailedNotFound() |
|
| 255 | + { |
|
| 256 | + |
|
| 257 | + return $this->setStatusCode(446) |
|
| 258 | + ->setStatusText('fail') |
|
| 259 | + ->setErrorCode(1001) |
|
| 260 | + ->respondWithMessage(); |
|
| 261 | + |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * The request failed is doublicated |
|
| 266 | + * @return mixed |
|
| 267 | + * @since August 24, 2016 |
|
| 268 | + * @author Mehdi Hosseini <[email protected]> |
|
| 269 | + */ |
|
| 270 | + public function requestFailedDuplicated() |
|
| 271 | + { |
|
| 272 | + |
|
| 273 | + return $this->setStatusCode(400) |
|
| 274 | + ->setStatusText('fail') |
|
| 275 | + ->SetErrorCode(1004) |
|
| 276 | + ->respondWithMessage(); |
|
| 277 | + |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * Custom error message according to error config file |
|
| 282 | + * @param $code integer |
|
| 283 | + * @return mixed |
|
| 284 | + * @author Mehdi Hosseini <[email protected]> |
|
| 285 | + * @since August 24, 2016 |
|
| 286 | + */ |
|
| 287 | + public function error($code) |
|
| 288 | + { |
|
| 289 | + |
|
| 290 | + return $this->setStatusCode(400) |
|
| 291 | + ->setStatusText('fail') |
|
| 292 | + ->setErrorCode($code) |
|
| 293 | + ->respondWithMessage(); |
|
| 294 | + |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | 297 | |
| 298 | 298 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | |
| 38 | 38 | if (is_null($message)) |
| 39 | - $message = $this->config['success']['delete']; |
|
| 39 | + $message = $this->config[ 'success' ][ 'delete' ]; |
|
| 40 | 40 | |
| 41 | 41 | return $this->setStatusCode(200) |
| 42 | 42 | ->setStatusText('success') |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | |
| 59 | 59 | if (is_null($message)) |
| 60 | - $message = $this->config['success']['update']; |
|
| 60 | + $message = $this->config[ 'success' ][ 'update' ]; |
|
| 61 | 61 | |
| 62 | 62 | return $this->setStatusCode(200) |
| 63 | 63 | ->setStatusText('success') |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | |
| 80 | 80 | if (is_null($message)) |
| 81 | - $message = $this->config['success']['insert']; |
|
| 81 | + $message = $this->config[ 'success' ][ 'insert' ]; |
|
| 82 | 82 | |
| 83 | 83 | return $this->setStatusCode(200) |
| 84 | 84 | ->setStatusText('success') |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | |
| 101 | 101 | if (is_null($message)) |
| 102 | - $message = $this->config['fail']['delete']; |
|
| 102 | + $message = $this->config[ 'fail' ][ 'delete' ]; |
|
| 103 | 103 | |
| 104 | 104 | return $this->setStatusCode(447) |
| 105 | 105 | ->setStatusText('fail') |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | |
| 123 | 123 | if (is_null($message)) |
| 124 | - $message = $this->config['fail']['update']; |
|
| 124 | + $message = $this->config[ 'fail' ][ 'update' ]; |
|
| 125 | 125 | |
| 126 | 126 | return $this->setStatusCode(449) |
| 127 | 127 | ->setStatusText('fail') |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | |
| 145 | 145 | if (is_null($message)) |
| 146 | - $message = $this->config['fail']['insert']; |
|
| 146 | + $message = $this->config[ 'fail' ][ 'insert' ]; |
|
| 147 | 147 | |
| 148 | 148 | return $this->setStatusCode(448) |
| 149 | 149 | ->setStatusText('fail') |
@@ -35,8 +35,9 @@ discard block |
||
| 35 | 35 | public function deleteSucceeded($message = null) |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - if (is_null($message)) |
|
| 39 | - $message = $this->config['success']['delete']; |
|
| 38 | + if (is_null($message)) { |
|
| 39 | + $message = $this->config['success']['delete']; |
|
| 40 | + } |
|
| 40 | 41 | |
| 41 | 42 | return $this->setStatusCode(200) |
| 42 | 43 | ->setStatusText('success') |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | public function updateSucceeded($message = null) |
| 57 | 58 | { |
| 58 | 59 | |
| 59 | - if (is_null($message)) |
|
| 60 | - $message = $this->config['success']['update']; |
|
| 60 | + if (is_null($message)) { |
|
| 61 | + $message = $this->config['success']['update']; |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | return $this->setStatusCode(200) |
| 63 | 65 | ->setStatusText('success') |
@@ -77,8 +79,9 @@ discard block |
||
| 77 | 79 | public function insertSucceeded($message = null) |
| 78 | 80 | { |
| 79 | 81 | |
| 80 | - if (is_null($message)) |
|
| 81 | - $message = $this->config['success']['insert']; |
|
| 82 | + if (is_null($message)) { |
|
| 83 | + $message = $this->config['success']['insert']; |
|
| 84 | + } |
|
| 82 | 85 | |
| 83 | 86 | return $this->setStatusCode(200) |
| 84 | 87 | ->setStatusText('success') |
@@ -98,8 +101,9 @@ discard block |
||
| 98 | 101 | public function deleteFailed($message = null) |
| 99 | 102 | { |
| 100 | 103 | |
| 101 | - if (is_null($message)) |
|
| 102 | - $message = $this->config['fail']['delete']; |
|
| 104 | + if (is_null($message)) { |
|
| 105 | + $message = $this->config['fail']['delete']; |
|
| 106 | + } |
|
| 103 | 107 | |
| 104 | 108 | return $this->setStatusCode(447) |
| 105 | 109 | ->setStatusText('fail') |
@@ -120,8 +124,9 @@ discard block |
||
| 120 | 124 | public function updateFailed($message = null) |
| 121 | 125 | { |
| 122 | 126 | |
| 123 | - if (is_null($message)) |
|
| 124 | - $message = $this->config['fail']['update']; |
|
| 127 | + if (is_null($message)) { |
|
| 128 | + $message = $this->config['fail']['update']; |
|
| 129 | + } |
|
| 125 | 130 | |
| 126 | 131 | return $this->setStatusCode(449) |
| 127 | 132 | ->setStatusText('fail') |
@@ -142,8 +147,9 @@ discard block |
||
| 142 | 147 | public function insertFailed($message = null) |
| 143 | 148 | { |
| 144 | 149 | |
| 145 | - if (is_null($message)) |
|
| 146 | - $message = $this->config['fail']['insert']; |
|
| 150 | + if (is_null($message)) { |
|
| 151 | + $message = $this->config['fail']['insert']; |
|
| 152 | + } |
|
| 147 | 153 | |
| 148 | 154 | return $this->setStatusCode(448) |
| 149 | 155 | ->setStatusText('fail') |
@@ -6,49 +6,49 @@ |
||
| 6 | 6 | |
| 7 | 7 | class RespondServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Perform post-registration booting of services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 9 | + /** |
|
| 10 | + * Perform post-registration booting of services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | 16 | |
| 17 | - if (class_exists('\App')) { |
|
| 18 | - $lang = \App::getLocale(); |
|
| 19 | - } else { |
|
| 20 | - $lang = /** @scrutinizer ignore-call */ |
|
| 21 | - app('translator')->getLocale(); |
|
| 22 | - } |
|
| 17 | + if (class_exists('\App')) { |
|
| 18 | + $lang = \App::getLocale(); |
|
| 19 | + } else { |
|
| 20 | + $lang = /** @scrutinizer ignore-call */ |
|
| 21 | + app('translator')->getLocale(); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - $this->publishes([ |
|
| 25 | - __DIR__ . '/../errors/lang/' . $lang . '.php' => config_path($lang . '.php'), |
|
| 26 | - ]); |
|
| 24 | + $this->publishes([ |
|
| 25 | + __DIR__ . '/../errors/lang/' . $lang . '.php' => config_path($lang . '.php'), |
|
| 26 | + ]); |
|
| 27 | 27 | |
| 28 | - } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Register any package services. |
|
| 33 | - * |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 36 | - public function register() |
|
| 37 | - { |
|
| 31 | + /** |
|
| 32 | + * Register any package services. |
|
| 33 | + * |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | + public function register() |
|
| 37 | + { |
|
| 38 | 38 | |
| 39 | - $this->registerMessages(); |
|
| 39 | + $this->registerMessages(); |
|
| 40 | 40 | |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - private function registerMessages() |
|
| 44 | - { |
|
| 43 | + private function registerMessages() |
|
| 44 | + { |
|
| 45 | 45 | |
| 46 | - $this->app->bind('Vahid\Respond\Messages', function () { |
|
| 46 | + $this->app->bind('Vahid\Respond\Messages', function () { |
|
| 47 | 47 | |
| 48 | - return new Messages(); |
|
| 48 | + return new Messages(); |
|
| 49 | 49 | |
| 50 | - }); |
|
| 50 | + }); |
|
| 51 | 51 | |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | private function registerMessages() |
| 44 | 44 | { |
| 45 | 45 | |
| 46 | - $this->app->bind('Vahid\Respond\Messages', function () { |
|
| 46 | + $this->app->bind('Vahid\Respond\Messages', function() { |
|
| 47 | 47 | |
| 48 | 48 | return new Messages(); |
| 49 | 49 | |
@@ -28,14 +28,14 @@ |
||
| 28 | 28 | { |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Get the registered name of the component. |
|
| 33 | - * |
|
| 34 | - * @return string |
|
| 35 | - */ |
|
| 36 | - protected static function getFacadeAccessor() |
|
| 37 | - { |
|
| 38 | - return 'Vahid\Respond\Messages'; |
|
| 39 | - } |
|
| 31 | + /** |
|
| 32 | + * Get the registered name of the component. |
|
| 33 | + * |
|
| 34 | + * @return string |
|
| 35 | + */ |
|
| 36 | + protected static function getFacadeAccessor() |
|
| 37 | + { |
|
| 38 | + return 'Vahid\Respond\Messages'; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | } |