@@ -12,98 +12,98 @@ discard block |
||
| 12 | 12 | class EpormasCategoryController extends Controller |
| 13 | 13 | {
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Display a listing of the resource. |
|
| 17 | - * |
|
| 18 | - * @return Response |
|
| 19 | - */ |
|
| 20 | - public function index() |
|
| 21 | - {
|
|
| 22 | - try {
|
|
| 23 | - $error = false; |
|
| 24 | - $statusCode = 200; |
|
| 25 | - $title = 'Success'; |
|
| 26 | - $type = 'success'; |
|
| 27 | - $message = 'Success'; |
|
| 28 | - $result = EpormasCategory::all(); |
|
| 29 | - return Response::json(array( |
|
| 15 | + /** |
|
| 16 | + * Display a listing of the resource. |
|
| 17 | + * |
|
| 18 | + * @return Response |
|
| 19 | + */ |
|
| 20 | + public function index() |
|
| 21 | + {
|
|
| 22 | + try {
|
|
| 23 | + $error = false; |
|
| 24 | + $statusCode = 200; |
|
| 25 | + $title = 'Success'; |
|
| 26 | + $type = 'success'; |
|
| 27 | + $message = 'Success'; |
|
| 28 | + $result = EpormasCategory::all(); |
|
| 29 | + return Response::json(array( |
|
| 30 | 30 | 'error' => $error, |
| 31 | 31 | 'status' => $statusCode, |
| 32 | 32 | 'title' => $title, |
| 33 | 33 | 'type' => $type, |
| 34 | 34 | 'message' => $message, |
| 35 | 35 | 'result' => $result |
| 36 | - )); |
|
| 37 | - } catch (Exception $e) {
|
|
| 38 | - $error = true; |
|
| 39 | - $statusCode = 404; |
|
| 40 | - $title = 'Error'; |
|
| 41 | - $type = 'error'; |
|
| 42 | - $message = 'Error'; |
|
| 43 | - $result = 'Not Found'; |
|
| 44 | - return Response::json(array( |
|
| 36 | + )); |
|
| 37 | + } catch (Exception $e) {
|
|
| 38 | + $error = true; |
|
| 39 | + $statusCode = 404; |
|
| 40 | + $title = 'Error'; |
|
| 41 | + $type = 'error'; |
|
| 42 | + $message = 'Error'; |
|
| 43 | + $result = 'Not Found'; |
|
| 44 | + return Response::json(array( |
|
| 45 | 45 | 'error' => $error, |
| 46 | 46 | 'status' => $statusCode, |
| 47 | 47 | 'title' => $title, |
| 48 | 48 | 'type' => $type, |
| 49 | 49 | 'message' => $message, |
| 50 | 50 | 'result' => $result |
| 51 | - )); |
|
| 52 | - } |
|
| 53 | - } |
|
| 51 | + )); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Show the form for creating a new resource. |
|
| 57 | - * |
|
| 58 | - * @return Response |
|
| 59 | - */ |
|
| 60 | - public function create() |
|
| 61 | - {
|
|
| 55 | + /** |
|
| 56 | + * Show the form for creating a new resource. |
|
| 57 | + * |
|
| 58 | + * @return Response |
|
| 59 | + */ |
|
| 60 | + public function create() |
|
| 61 | + {
|
|
| 62 | 62 | |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Store a newly created resource in storage. |
|
| 67 | - * |
|
| 68 | - * @return Response |
|
| 69 | - */ |
|
| 70 | - public function store(Request $request, $version='') |
|
| 71 | - {
|
|
| 65 | + /** |
|
| 66 | + * Store a newly created resource in storage. |
|
| 67 | + * |
|
| 68 | + * @return Response |
|
| 69 | + */ |
|
| 70 | + public function store(Request $request, $version='') |
|
| 71 | + {
|
|
| 72 | 72 | $path = \Request::path(); |
| 73 | 73 | $explode = explode('/', $path);
|
| 74 | 74 | |
| 75 | 75 | $from = 'form'; |
| 76 | 76 | if(in_array('api',$explode)){
|
| 77 | - $from = 'api'; |
|
| 77 | + $from = 'api'; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $via = $from; |
| 81 | 81 | if($version != '' && $version != 'store'){
|
| 82 | - $via .= '-'.$version; |
|
| 82 | + $via .= '-'.$version; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $rules = [ |
|
| 85 | + $rules = [ |
|
| 86 | 86 | 'name' => 'required' |
| 87 | 87 | ]; |
| 88 | 88 | |
| 89 | 89 | $validator = Validator::make($request->all(), $rules); |
| 90 | 90 | if ($validator->fails()) {
|
| 91 | - return Response::json(array( |
|
| 92 | - 'title' => 'Error', |
|
| 93 | - 'type' => 'error', |
|
| 94 | - 'message' => $validator->errors()->all() |
|
| 95 | - )); |
|
| 91 | + return Response::json(array( |
|
| 92 | + 'title' => 'Error', |
|
| 93 | + 'type' => 'error', |
|
| 94 | + 'message' => $validator->errors()->all() |
|
| 95 | + )); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | $data = EpormasCategory::whereNull('deleted_at')
|
| 99 | 99 | ->where('name', $request->name)
|
| 100 | 100 | ->count(); |
| 101 | 101 | if($data > 0){
|
| 102 | - return Response::json(array( |
|
| 103 | - 'title' => 'Error', |
|
| 104 | - 'type' => 'error', |
|
| 105 | - 'message' => 'Data has already been taken.' |
|
| 106 | - )); |
|
| 102 | + return Response::json(array( |
|
| 103 | + 'title' => 'Error', |
|
| 104 | + 'type' => 'error', |
|
| 105 | + 'message' => 'Data has already been taken.' |
|
| 106 | + )); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | try {
|
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | 'name' => $request->name |
| 117 | 117 | ]); |
| 118 | 118 | return Response::json(array( |
| 119 | - 'error' => $error, |
|
| 120 | - 'status' => $statusCode, |
|
| 121 | - 'title' => $title, |
|
| 122 | - 'type' => $type, |
|
| 123 | - 'message' => $message, |
|
| 124 | - 'result' => $result |
|
| 119 | + 'error' => $error, |
|
| 120 | + 'status' => $statusCode, |
|
| 121 | + 'title' => $title, |
|
| 122 | + 'type' => $type, |
|
| 123 | + 'message' => $message, |
|
| 124 | + 'result' => $result |
|
| 125 | 125 | )); |
| 126 | 126 | } catch (Exception $e) {
|
| 127 | 127 | $error = true; |
@@ -131,24 +131,24 @@ discard block |
||
| 131 | 131 | $message = 'Error'; |
| 132 | 132 | $result = 'Not Found'; |
| 133 | 133 | return Response::json(array( |
| 134 | - 'error' => $error, |
|
| 135 | - 'status' => $statusCode, |
|
| 136 | - 'title' => $title, |
|
| 137 | - 'type' => $type, |
|
| 138 | - 'message' => $message, |
|
| 139 | - 'result' => $result |
|
| 134 | + 'error' => $error, |
|
| 135 | + 'status' => $statusCode, |
|
| 136 | + 'title' => $title, |
|
| 137 | + 'type' => $type, |
|
| 138 | + 'message' => $message, |
|
| 139 | + 'result' => $result |
|
| 140 | 140 | )); |
| 141 | 141 | } |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * Display the specified resource. |
|
| 146 | - * |
|
| 147 | - * @param int $id |
|
| 148 | - * @return Response |
|
| 149 | - */ |
|
| 150 | - public function show($version='', $id) |
|
| 151 | - {
|
|
| 144 | + /** |
|
| 145 | + * Display the specified resource. |
|
| 146 | + * |
|
| 147 | + * @param int $id |
|
| 148 | + * @return Response |
|
| 149 | + */ |
|
| 150 | + public function show($version='', $id) |
|
| 151 | + {
|
|
| 152 | 152 | try {
|
| 153 | 153 | $error = false; |
| 154 | 154 | $statusCode = 200; |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | $message = 'Success'; |
| 158 | 158 | $result = EpormasCategory::findOrFail($id); |
| 159 | 159 | return Response::json(array( |
| 160 | - 'error' => $error, |
|
| 161 | - 'status' => $statusCode, |
|
| 162 | - 'title' => $title, |
|
| 163 | - 'type' => $type, |
|
| 164 | - 'message' => $message, |
|
| 165 | - 'result' => $result |
|
| 160 | + 'error' => $error, |
|
| 161 | + 'status' => $statusCode, |
|
| 162 | + 'title' => $title, |
|
| 163 | + 'type' => $type, |
|
| 164 | + 'message' => $message, |
|
| 165 | + 'result' => $result |
|
| 166 | 166 | )); |
| 167 | 167 | } catch (Exception $e) {
|
| 168 | 168 | $error = true; |
@@ -172,24 +172,24 @@ discard block |
||
| 172 | 172 | $message = 'Error'; |
| 173 | 173 | $result = 'Not Found'; |
| 174 | 174 | return Response::json(array( |
| 175 | - 'error' => $error, |
|
| 176 | - 'status' => $statusCode, |
|
| 177 | - 'title' => $title, |
|
| 178 | - 'type' => $type, |
|
| 179 | - 'message' => $message, |
|
| 180 | - 'result' => $result |
|
| 175 | + 'error' => $error, |
|
| 176 | + 'status' => $statusCode, |
|
| 177 | + 'title' => $title, |
|
| 178 | + 'type' => $type, |
|
| 179 | + 'message' => $message, |
|
| 180 | + 'result' => $result |
|
| 181 | 181 | )); |
| 182 | 182 | } |
| 183 | - } |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Show the form for editing the specified resource. |
|
| 187 | - * |
|
| 188 | - * @param int $id |
|
| 189 | - * @return Response |
|
| 190 | - */ |
|
| 191 | - public function edit($id) |
|
| 192 | - {
|
|
| 185 | + /** |
|
| 186 | + * Show the form for editing the specified resource. |
|
| 187 | + * |
|
| 188 | + * @param int $id |
|
| 189 | + * @return Response |
|
| 190 | + */ |
|
| 191 | + public function edit($id) |
|
| 192 | + {
|
|
| 193 | 193 | try {
|
| 194 | 194 | $error = false; |
| 195 | 195 | $statusCode = 200; |
@@ -198,12 +198,12 @@ discard block |
||
| 198 | 198 | $message = 'Success'; |
| 199 | 199 | $result = EpormasCategory::findOrFail($id); |
| 200 | 200 | return Response::json(array( |
| 201 | - 'error' => $error, |
|
| 202 | - 'status' => $statusCode, |
|
| 203 | - 'title' => $title, |
|
| 204 | - 'type' => $type, |
|
| 205 | - 'message' => $message, |
|
| 206 | - 'result' => $result |
|
| 201 | + 'error' => $error, |
|
| 202 | + 'status' => $statusCode, |
|
| 203 | + 'title' => $title, |
|
| 204 | + 'type' => $type, |
|
| 205 | + 'message' => $message, |
|
| 206 | + 'result' => $result |
|
| 207 | 207 | )); |
| 208 | 208 | } catch (Exception $e) {
|
| 209 | 209 | $error = true; |
@@ -213,24 +213,24 @@ discard block |
||
| 213 | 213 | $message = 'Error'; |
| 214 | 214 | $result = 'Not Found'; |
| 215 | 215 | return Response::json(array( |
| 216 | - 'error' => $error, |
|
| 217 | - 'status' => $statusCode, |
|
| 218 | - 'title' => $title, |
|
| 219 | - 'type' => $type, |
|
| 220 | - 'message' => $message, |
|
| 221 | - 'result' => $result |
|
| 216 | + 'error' => $error, |
|
| 217 | + 'status' => $statusCode, |
|
| 218 | + 'title' => $title, |
|
| 219 | + 'type' => $type, |
|
| 220 | + 'message' => $message, |
|
| 221 | + 'result' => $result |
|
| 222 | 222 | )); |
| 223 | 223 | } |
| 224 | - } |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Update the specified resource in storage. |
|
| 228 | - * |
|
| 229 | - * @param int $id |
|
| 230 | - * @return Response |
|
| 231 | - */ |
|
| 232 | - public function update(Request $request, $version='', $id) |
|
| 233 | - {
|
|
| 226 | + /** |
|
| 227 | + * Update the specified resource in storage. |
|
| 228 | + * |
|
| 229 | + * @param int $id |
|
| 230 | + * @return Response |
|
| 231 | + */ |
|
| 232 | + public function update(Request $request, $version='', $id) |
|
| 233 | + {
|
|
| 234 | 234 | $result = EpormasCategory::find($id); |
| 235 | 235 | |
| 236 | 236 | $rules = [ |
@@ -239,23 +239,23 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | $validator = Validator::make($request->all(), $rules); |
| 241 | 241 | if ($validator->fails()) {
|
| 242 | - return Response::json(array( |
|
| 243 | - 'type' => 'error', |
|
| 244 | - 'message' => $validator->errors()->all() |
|
| 245 | - )); |
|
| 242 | + return Response::json(array( |
|
| 243 | + 'type' => 'error', |
|
| 244 | + 'message' => $validator->errors()->all() |
|
| 245 | + )); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | if($request->name != $result->name){
|
| 249 | - $data = EpormasCategory::whereNull('deleted_at')
|
|
| 250 | - ->where('name', $request->name)
|
|
| 251 | - ->count(); |
|
| 252 | - if($data > 0){
|
|
| 249 | + $data = EpormasCategory::whereNull('deleted_at')
|
|
| 250 | + ->where('name', $request->name)
|
|
| 251 | + ->count(); |
|
| 252 | + if($data > 0){
|
|
| 253 | 253 | return Response::json(array( |
| 254 | 254 | 'title' => 'Error', |
| 255 | 255 | 'type' => 'error', |
| 256 | 256 | 'message' => 'Data has already been taken.' |
| 257 | 257 | )); |
| 258 | - } |
|
| 258 | + } |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | $path = \Request::path(); |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | $from = 'form'; |
| 265 | 265 | if(in_array('api',$explode)){
|
| 266 | - $from = 'api'; |
|
| 266 | + $from = 'api'; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | $via = $from; |
| 270 | 270 | if($version != '' && $version != 'update'){
|
| 271 | - $via .= '-'.$version; |
|
| 271 | + $via .= '-'.$version; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | try {
|
@@ -281,12 +281,12 @@ discard block |
||
| 281 | 281 | 'name' => $request->name |
| 282 | 282 | ]); |
| 283 | 283 | return Response::json(array( |
| 284 | - 'error' => $error, |
|
| 285 | - 'status' => $statusCode, |
|
| 286 | - 'title' => $title, |
|
| 287 | - 'type' => $type, |
|
| 288 | - 'message' => $message, |
|
| 289 | - 'result' => $result |
|
| 284 | + 'error' => $error, |
|
| 285 | + 'status' => $statusCode, |
|
| 286 | + 'title' => $title, |
|
| 287 | + 'type' => $type, |
|
| 288 | + 'message' => $message, |
|
| 289 | + 'result' => $result |
|
| 290 | 290 | )); |
| 291 | 291 | } catch (Exception $e) {
|
| 292 | 292 | $error = true; |
@@ -296,53 +296,53 @@ discard block |
||
| 296 | 296 | $message = 'Error'; |
| 297 | 297 | $result = 'Not Found'; |
| 298 | 298 | return Response::json(array( |
| 299 | - 'error' => $error, |
|
| 300 | - 'status' => $statusCode, |
|
| 301 | - 'title' => $title, |
|
| 302 | - 'type' => $type, |
|
| 303 | - 'message' => $message, |
|
| 304 | - 'result' => $result |
|
| 299 | + 'error' => $error, |
|
| 300 | + 'status' => $statusCode, |
|
| 301 | + 'title' => $title, |
|
| 302 | + 'type' => $type, |
|
| 303 | + 'message' => $message, |
|
| 304 | + 'result' => $result |
|
| 305 | 305 | )); |
| 306 | 306 | } |
| 307 | - } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - /** |
|
| 310 | - * Remove the specified resource from storage. |
|
| 311 | - * |
|
| 312 | - * @param int $id |
|
| 313 | - * @return Response |
|
| 314 | - */ |
|
| 315 | - public function destroy($id) |
|
| 316 | - {
|
|
| 317 | - try {
|
|
| 318 | - EpormasCategory::find($id)->delete(); |
|
| 319 | - $error = false; |
|
| 320 | - $statusCode = 200; |
|
| 321 | - $title = 'Success'; |
|
| 322 | - $type = 'success'; |
|
| 323 | - $message = 'Data deleted successfully'; |
|
| 324 | - return Response::json(array( |
|
| 309 | + /** |
|
| 310 | + * Remove the specified resource from storage. |
|
| 311 | + * |
|
| 312 | + * @param int $id |
|
| 313 | + * @return Response |
|
| 314 | + */ |
|
| 315 | + public function destroy($id) |
|
| 316 | + {
|
|
| 317 | + try {
|
|
| 318 | + EpormasCategory::find($id)->delete(); |
|
| 319 | + $error = false; |
|
| 320 | + $statusCode = 200; |
|
| 321 | + $title = 'Success'; |
|
| 322 | + $type = 'success'; |
|
| 323 | + $message = 'Data deleted successfully'; |
|
| 324 | + return Response::json(array( |
|
| 325 | 325 | 'error' => $error, |
| 326 | 326 | 'status' => $statusCode, |
| 327 | 327 | 'title' => $title, |
| 328 | 328 | 'type' => $type, |
| 329 | 329 | 'message' => $message |
| 330 | - )); |
|
| 331 | - } catch (Exception $e) {
|
|
| 332 | - $error = true; |
|
| 333 | - $statusCode = 404; |
|
| 334 | - $title = 'Error'; |
|
| 335 | - $type = 'error'; |
|
| 336 | - $message = 'Error'; |
|
| 337 | - return Response::json(array( |
|
| 330 | + )); |
|
| 331 | + } catch (Exception $e) {
|
|
| 332 | + $error = true; |
|
| 333 | + $statusCode = 404; |
|
| 334 | + $title = 'Error'; |
|
| 335 | + $type = 'error'; |
|
| 336 | + $message = 'Error'; |
|
| 337 | + return Response::json(array( |
|
| 338 | 338 | 'error' => $error, |
| 339 | 339 | 'status' => $statusCode, |
| 340 | 340 | 'title' => $title, |
| 341 | 341 | 'type' => $type, |
| 342 | 342 | 'message' => $message |
| 343 | - )); |
|
| 344 | - } |
|
| 345 | - } |
|
| 343 | + )); |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | 347 | } |
| 348 | 348 | |
@@ -67,18 +67,18 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return Response |
| 69 | 69 | */ |
| 70 | - public function store(Request $request, $version='') |
|
| 70 | + public function store(Request $request, $version = '') |
|
| 71 | 71 | {
|
| 72 | 72 | $path = \Request::path(); |
| 73 | 73 | $explode = explode('/', $path);
|
| 74 | 74 | |
| 75 | 75 | $from = 'form'; |
| 76 | - if(in_array('api',$explode)){
|
|
| 76 | + if (in_array('api', $explode)) {
|
|
| 77 | 77 | $from = 'api'; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $via = $from; |
| 81 | - if($version != '' && $version != 'store'){
|
|
| 81 | + if ($version != '' && $version != 'store') {
|
|
| 82 | 82 | $via .= '-'.$version; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $data = EpormasCategory::whereNull('deleted_at')
|
| 99 | 99 | ->where('name', $request->name)
|
| 100 | 100 | ->count(); |
| 101 | - if($data > 0){
|
|
| 101 | + if ($data > 0) {
|
|
| 102 | 102 | return Response::json(array( |
| 103 | 103 | 'title' => 'Error', |
| 104 | 104 | 'type' => 'error', |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param int $id |
| 148 | 148 | * @return Response |
| 149 | 149 | */ |
| 150 | - public function show($version='', $id) |
|
| 150 | + public function show($version = '', $id) |
|
| 151 | 151 | {
|
| 152 | 152 | try {
|
| 153 | 153 | $error = false; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param int $id |
| 230 | 230 | * @return Response |
| 231 | 231 | */ |
| 232 | - public function update(Request $request, $version='', $id) |
|
| 232 | + public function update(Request $request, $version = '', $id) |
|
| 233 | 233 | {
|
| 234 | 234 | $result = EpormasCategory::find($id); |
| 235 | 235 | |
@@ -245,11 +245,11 @@ discard block |
||
| 245 | 245 | )); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if($request->name != $result->name){
|
|
| 248 | + if ($request->name != $result->name) {
|
|
| 249 | 249 | $data = EpormasCategory::whereNull('deleted_at')
|
| 250 | 250 | ->where('name', $request->name)
|
| 251 | 251 | ->count(); |
| 252 | - if($data > 0){
|
|
| 252 | + if ($data > 0) {
|
|
| 253 | 253 | return Response::json(array( |
| 254 | 254 | 'title' => 'Error', |
| 255 | 255 | 'type' => 'error', |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | $explode = explode('/', $path);
|
| 263 | 263 | |
| 264 | 264 | $from = 'form'; |
| 265 | - if(in_array('api',$explode)){
|
|
| 265 | + if (in_array('api', $explode)) {
|
|
| 266 | 266 | $from = 'api'; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | $via = $from; |
| 270 | - if($version != '' && $version != 'update'){
|
|
| 270 | + if ($version != '' && $version != 'update') {
|
|
| 271 | 271 | $via .= '-'.$version; |
| 272 | 272 | } |
| 273 | 273 | |
@@ -14,65 +14,65 @@ discard block |
||
| 14 | 14 | class EpormasCounterController extends Controller |
| 15 | 15 | {
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Display a listing of the resource. |
|
| 19 | - * |
|
| 20 | - * @return Response |
|
| 21 | - */ |
|
| 22 | - public function index() |
|
| 23 | - {
|
|
| 24 | - try {
|
|
| 25 | - $error = false; |
|
| 26 | - $statusCode = 200; |
|
| 27 | - $title = 'Success'; |
|
| 28 | - $type = 'success'; |
|
| 29 | - $message = 'Success'; |
|
| 30 | - $result = EpormasCounter::whereNull('deleted_at')
|
|
| 31 | - ->with('getCity')
|
|
| 32 | - ->with('getCategory')
|
|
| 33 | - ->get(); |
|
| 34 | - return Response::json(array( |
|
| 17 | + /** |
|
| 18 | + * Display a listing of the resource. |
|
| 19 | + * |
|
| 20 | + * @return Response |
|
| 21 | + */ |
|
| 22 | + public function index() |
|
| 23 | + {
|
|
| 24 | + try {
|
|
| 25 | + $error = false; |
|
| 26 | + $statusCode = 200; |
|
| 27 | + $title = 'Success'; |
|
| 28 | + $type = 'success'; |
|
| 29 | + $message = 'Success'; |
|
| 30 | + $result = EpormasCounter::whereNull('deleted_at')
|
|
| 31 | + ->with('getCity')
|
|
| 32 | + ->with('getCategory')
|
|
| 33 | + ->get(); |
|
| 34 | + return Response::json(array( |
|
| 35 | 35 | 'error' => $error, |
| 36 | 36 | 'status' => $statusCode, |
| 37 | 37 | 'title' => $title, |
| 38 | 38 | 'type' => $type, |
| 39 | 39 | 'message' => $message, |
| 40 | 40 | 'result' => $result |
| 41 | - )); |
|
| 42 | - } catch (Exception $e) {
|
|
| 43 | - $error = true; |
|
| 44 | - $statusCode = 404; |
|
| 45 | - $title = 'Error'; |
|
| 46 | - $type = 'error'; |
|
| 47 | - $message = 'Error'; |
|
| 48 | - $result = 'Not Found'; |
|
| 49 | - return Response::json(array( |
|
| 41 | + )); |
|
| 42 | + } catch (Exception $e) {
|
|
| 43 | + $error = true; |
|
| 44 | + $statusCode = 404; |
|
| 45 | + $title = 'Error'; |
|
| 46 | + $type = 'error'; |
|
| 47 | + $message = 'Error'; |
|
| 48 | + $result = 'Not Found'; |
|
| 49 | + return Response::json(array( |
|
| 50 | 50 | 'error' => $error, |
| 51 | 51 | 'status' => $statusCode, |
| 52 | 52 | 'title' => $title, |
| 53 | 53 | 'type' => $type, |
| 54 | 54 | 'message' => $message, |
| 55 | 55 | 'result' => $result |
| 56 | - )); |
|
| 57 | - } |
|
| 58 | - } |
|
| 56 | + )); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Show the form for creating a new resource. |
|
| 62 | - * |
|
| 63 | - * @return Response |
|
| 64 | - */ |
|
| 65 | - public function create() |
|
| 66 | - {
|
|
| 67 | - try {
|
|
| 68 | - $error = false; |
|
| 69 | - $statusCode = 200; |
|
| 70 | - $title = 'Success'; |
|
| 71 | - $type = 'success'; |
|
| 72 | - $message = 'Success'; |
|
| 73 | - $city = EpormasCity::all(); |
|
| 74 | - $category = EpormasCategory::all(); |
|
| 75 | - return Response::json(array( |
|
| 60 | + /** |
|
| 61 | + * Show the form for creating a new resource. |
|
| 62 | + * |
|
| 63 | + * @return Response |
|
| 64 | + */ |
|
| 65 | + public function create() |
|
| 66 | + {
|
|
| 67 | + try {
|
|
| 68 | + $error = false; |
|
| 69 | + $statusCode = 200; |
|
| 70 | + $title = 'Success'; |
|
| 71 | + $type = 'success'; |
|
| 72 | + $message = 'Success'; |
|
| 73 | + $city = EpormasCity::all(); |
|
| 74 | + $category = EpormasCategory::all(); |
|
| 75 | + return Response::json(array( |
|
| 76 | 76 | 'error' => $error, |
| 77 | 77 | 'status' => $statusCode, |
| 78 | 78 | 'title' => $title, |
@@ -80,16 +80,16 @@ discard block |
||
| 80 | 80 | 'message' => $message, |
| 81 | 81 | 'city' => $city, |
| 82 | 82 | 'category' => $category |
| 83 | - )); |
|
| 84 | - } catch (Exception $e) {
|
|
| 85 | - $error = true; |
|
| 86 | - $statusCode = 404; |
|
| 87 | - $title = 'Error'; |
|
| 88 | - $type = 'error'; |
|
| 89 | - $message = 'Error'; |
|
| 90 | - $city = 'Not Found'; |
|
| 91 | - $category = 'Not Found'; |
|
| 92 | - return Response::json(array( |
|
| 83 | + )); |
|
| 84 | + } catch (Exception $e) {
|
|
| 85 | + $error = true; |
|
| 86 | + $statusCode = 404; |
|
| 87 | + $title = 'Error'; |
|
| 88 | + $type = 'error'; |
|
| 89 | + $message = 'Error'; |
|
| 90 | + $city = 'Not Found'; |
|
| 91 | + $category = 'Not Found'; |
|
| 92 | + return Response::json(array( |
|
| 93 | 93 | 'error' => $error, |
| 94 | 94 | 'status' => $statusCode, |
| 95 | 95 | 'title' => $title, |
@@ -97,31 +97,31 @@ discard block |
||
| 97 | 97 | 'message' => $message, |
| 98 | 98 | 'city' => $city, |
| 99 | 99 | 'category' => $category |
| 100 | - )); |
|
| 101 | - } |
|
| 102 | - } |
|
| 100 | + )); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Store a newly created resource in storage. |
|
| 106 | - * |
|
| 107 | - * @return Response |
|
| 108 | - */ |
|
| 109 | - public function store(Request $request, $version='') |
|
| 110 | - {
|
|
| 104 | + /** |
|
| 105 | + * Store a newly created resource in storage. |
|
| 106 | + * |
|
| 107 | + * @return Response |
|
| 108 | + */ |
|
| 109 | + public function store(Request $request, $version='') |
|
| 110 | + {
|
|
| 111 | 111 | $path = \Request::path(); |
| 112 | 112 | $explode = explode('/', $path);
|
| 113 | 113 | |
| 114 | 114 | $from = 'form'; |
| 115 | 115 | if(in_array('api',$explode)){
|
| 116 | - $from = 'api'; |
|
| 116 | + $from = 'api'; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $via = $from; |
| 120 | 120 | if($version != '' && $version != 'store'){
|
| 121 | - $via .= '-'.$version; |
|
| 121 | + $via .= '-'.$version; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $rules = [ |
|
| 124 | + $rules = [ |
|
| 125 | 125 | 'count' => 'required|numeric', |
| 126 | 126 | 'city_id' => 'required|numeric', |
| 127 | 127 | 'category_id' => 'required|numeric', |
@@ -130,44 +130,44 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | $validator = Validator::make($request->all(), $rules); |
| 132 | 132 | if ($validator->fails()) {
|
| 133 | - return Response::json(array( |
|
| 134 | - 'title' => 'Error', |
|
| 135 | - 'type' => 'error', |
|
| 136 | - 'message' => $validator->errors()->all() |
|
| 137 | - )); |
|
| 133 | + return Response::json(array( |
|
| 134 | + 'title' => 'Error', |
|
| 135 | + 'type' => 'error', |
|
| 136 | + 'message' => $validator->errors()->all() |
|
| 137 | + )); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
| 141 | 141 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 142 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 143 | - ->where('category_id',$request->category_id)
|
|
| 144 | - ->where('city_id',$request->city_id)
|
|
| 145 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 146 | - ->orderBy('bulan')
|
|
| 147 | - ->count(); |
|
| 142 | + ->where('tanggal','like','%'.$format.'%')
|
|
| 143 | + ->where('category_id',$request->category_id)
|
|
| 144 | + ->where('city_id',$request->city_id)
|
|
| 145 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 146 | + ->orderBy('bulan')
|
|
| 147 | + ->count(); |
|
| 148 | 148 | if($resultcek > 0){
|
| 149 | - return Response::json(array( |
|
| 150 | - 'title' => 'Error', |
|
| 151 | - 'type' => 'error', |
|
| 152 | - 'message' => 'Data has already been taken.' |
|
| 153 | - )); |
|
| 149 | + return Response::json(array( |
|
| 150 | + 'title' => 'Error', |
|
| 151 | + 'type' => 'error', |
|
| 152 | + 'message' => 'Data has already been taken.' |
|
| 153 | + )); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | $date = explode("-",$format);
|
| 157 | 157 | $data = EpormasCounter::whereNull('deleted_at')
|
| 158 | - ->where('tahun', $date[0])
|
|
| 159 | - ->where('bulan', $date[1])
|
|
| 160 | - ->where('category_id',$request->category_id)
|
|
| 161 | - ->where('city_id',$request->city_id)
|
|
| 162 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 163 | - ->orderBy('bulan')
|
|
| 164 | - ->count(); |
|
| 158 | + ->where('tahun', $date[0])
|
|
| 159 | + ->where('bulan', $date[1])
|
|
| 160 | + ->where('category_id',$request->category_id)
|
|
| 161 | + ->where('city_id',$request->city_id)
|
|
| 162 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 163 | + ->orderBy('bulan')
|
|
| 164 | + ->count(); |
|
| 165 | 165 | if($data > 0){
|
| 166 | - return Response::json(array( |
|
| 167 | - 'title' => 'Error', |
|
| 168 | - 'type' => 'error', |
|
| 169 | - 'message' => 'Data has already been taken.' |
|
| 170 | - )); |
|
| 166 | + return Response::json(array( |
|
| 167 | + 'title' => 'Error', |
|
| 168 | + 'type' => 'error', |
|
| 169 | + 'message' => 'Data has already been taken.' |
|
| 170 | + )); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | try {
|
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | 'via' => $via |
| 188 | 188 | ]); |
| 189 | 189 | return Response::json(array( |
| 190 | - 'error' => $error, |
|
| 191 | - 'status' => $statusCode, |
|
| 192 | - 'title' => $title, |
|
| 193 | - 'type' => $type, |
|
| 194 | - 'message' => $message, |
|
| 195 | - 'result' => $result |
|
| 190 | + 'error' => $error, |
|
| 191 | + 'status' => $statusCode, |
|
| 192 | + 'title' => $title, |
|
| 193 | + 'type' => $type, |
|
| 194 | + 'message' => $message, |
|
| 195 | + 'result' => $result |
|
| 196 | 196 | )); |
| 197 | 197 | } catch (Exception $e) {
|
| 198 | 198 | $error = true; |
@@ -202,24 +202,24 @@ discard block |
||
| 202 | 202 | $message = 'Error'; |
| 203 | 203 | $result = 'Not Found'; |
| 204 | 204 | return Response::json(array( |
| 205 | - 'error' => $error, |
|
| 206 | - 'status' => $statusCode, |
|
| 207 | - 'title' => $title, |
|
| 208 | - 'type' => $type, |
|
| 209 | - 'message' => $message, |
|
| 210 | - 'result' => $result |
|
| 205 | + 'error' => $error, |
|
| 206 | + 'status' => $statusCode, |
|
| 207 | + 'title' => $title, |
|
| 208 | + 'type' => $type, |
|
| 209 | + 'message' => $message, |
|
| 210 | + 'result' => $result |
|
| 211 | 211 | )); |
| 212 | 212 | } |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Display the specified resource. |
|
| 217 | - * |
|
| 218 | - * @param int $id |
|
| 219 | - * @return Response |
|
| 220 | - */ |
|
| 221 | - public function show($version='', $id) |
|
| 222 | - {
|
|
| 215 | + /** |
|
| 216 | + * Display the specified resource. |
|
| 217 | + * |
|
| 218 | + * @param int $id |
|
| 219 | + * @return Response |
|
| 220 | + */ |
|
| 221 | + public function show($version='', $id) |
|
| 222 | + {
|
|
| 223 | 223 | try {
|
| 224 | 224 | $error = false; |
| 225 | 225 | $statusCode = 200; |
@@ -231,12 +231,12 @@ discard block |
||
| 231 | 231 | ->with('getCategory')
|
| 232 | 232 | ->find($id); |
| 233 | 233 | return Response::json(array( |
| 234 | - 'error' => $error, |
|
| 235 | - 'status' => $statusCode, |
|
| 236 | - 'title' => $title, |
|
| 237 | - 'type' => $type, |
|
| 238 | - 'message' => $message, |
|
| 239 | - 'result' => $result |
|
| 234 | + 'error' => $error, |
|
| 235 | + 'status' => $statusCode, |
|
| 236 | + 'title' => $title, |
|
| 237 | + 'type' => $type, |
|
| 238 | + 'message' => $message, |
|
| 239 | + 'result' => $result |
|
| 240 | 240 | )); |
| 241 | 241 | } catch (Exception $e) {
|
| 242 | 242 | $error = true; |
@@ -246,24 +246,24 @@ discard block |
||
| 246 | 246 | $message = 'Error'; |
| 247 | 247 | $result = 'Not Found'; |
| 248 | 248 | return Response::json(array( |
| 249 | - 'error' => $error, |
|
| 250 | - 'status' => $statusCode, |
|
| 251 | - 'title' => $title, |
|
| 252 | - 'type' => $type, |
|
| 253 | - 'message' => $message, |
|
| 254 | - 'result' => $result |
|
| 249 | + 'error' => $error, |
|
| 250 | + 'status' => $statusCode, |
|
| 251 | + 'title' => $title, |
|
| 252 | + 'type' => $type, |
|
| 253 | + 'message' => $message, |
|
| 254 | + 'result' => $result |
|
| 255 | 255 | )); |
| 256 | 256 | } |
| 257 | - } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Show the form for editing the specified resource. |
|
| 261 | - * |
|
| 262 | - * @param int $id |
|
| 263 | - * @return Response |
|
| 264 | - */ |
|
| 265 | - public function edit($id) |
|
| 266 | - {
|
|
| 259 | + /** |
|
| 260 | + * Show the form for editing the specified resource. |
|
| 261 | + * |
|
| 262 | + * @param int $id |
|
| 263 | + * @return Response |
|
| 264 | + */ |
|
| 265 | + public function edit($id) |
|
| 266 | + {
|
|
| 267 | 267 | try {
|
| 268 | 268 | $error = false; |
| 269 | 269 | $statusCode = 200; |
@@ -278,15 +278,15 @@ discard block |
||
| 278 | 278 | ->find($id); |
| 279 | 279 | $format = date('Y-m-d', strtotime($result->tanggal));
|
| 280 | 280 | return Response::json(array( |
| 281 | - 'error' => $error, |
|
| 282 | - 'status' => $statusCode, |
|
| 283 | - 'title' => $title, |
|
| 284 | - 'type' => $type, |
|
| 285 | - 'message' => $message, |
|
| 286 | - 'result' => $result, |
|
| 287 | - 'city' => $city, |
|
| 288 | - 'tanggal' => $format, |
|
| 289 | - 'category' => $category |
|
| 281 | + 'error' => $error, |
|
| 282 | + 'status' => $statusCode, |
|
| 283 | + 'title' => $title, |
|
| 284 | + 'type' => $type, |
|
| 285 | + 'message' => $message, |
|
| 286 | + 'result' => $result, |
|
| 287 | + 'city' => $city, |
|
| 288 | + 'tanggal' => $format, |
|
| 289 | + 'category' => $category |
|
| 290 | 290 | )); |
| 291 | 291 | } catch (Exception $e) {
|
| 292 | 292 | $error = true; |
@@ -299,27 +299,27 @@ discard block |
||
| 299 | 299 | $format = 'Not Found'; |
| 300 | 300 | $category = 'Not Found'; |
| 301 | 301 | return Response::json(array( |
| 302 | - 'error' => $error, |
|
| 303 | - 'status' => $statusCode, |
|
| 304 | - 'title' => $title, |
|
| 305 | - 'type' => $type, |
|
| 306 | - 'message' => $message, |
|
| 307 | - 'result' => $result, |
|
| 308 | - 'city' => $city, |
|
| 309 | - 'tanggal' => $format, |
|
| 310 | - 'category' => $category |
|
| 302 | + 'error' => $error, |
|
| 303 | + 'status' => $statusCode, |
|
| 304 | + 'title' => $title, |
|
| 305 | + 'type' => $type, |
|
| 306 | + 'message' => $message, |
|
| 307 | + 'result' => $result, |
|
| 308 | + 'city' => $city, |
|
| 309 | + 'tanggal' => $format, |
|
| 310 | + 'category' => $category |
|
| 311 | 311 | )); |
| 312 | 312 | } |
| 313 | - } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - /** |
|
| 316 | - * Update the specified resource in storage. |
|
| 317 | - * |
|
| 318 | - * @param int $id |
|
| 319 | - * @return Response |
|
| 320 | - */ |
|
| 321 | - public function update(Request $request, $version='', $id) |
|
| 322 | - {
|
|
| 315 | + /** |
|
| 316 | + * Update the specified resource in storage. |
|
| 317 | + * |
|
| 318 | + * @param int $id |
|
| 319 | + * @return Response |
|
| 320 | + */ |
|
| 321 | + public function update(Request $request, $version='', $id) |
|
| 322 | + {
|
|
| 323 | 323 | $result = EpormasCounter::whereNull('deleted_at')
|
| 324 | 324 | ->with('getCity')
|
| 325 | 325 | ->with('getCategory')
|
@@ -334,28 +334,28 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | $validator = Validator::make($request->all(), $rules); |
| 336 | 336 | if ($validator->fails()) {
|
| 337 | - return Response::json(array( |
|
| 338 | - 'title' => 'Error', |
|
| 339 | - 'type' => 'error', |
|
| 340 | - 'message' => $validator->errors()->all() |
|
| 341 | - )); |
|
| 337 | + return Response::json(array( |
|
| 338 | + 'title' => 'Error', |
|
| 339 | + 'type' => 'error', |
|
| 340 | + 'message' => $validator->errors()->all() |
|
| 341 | + )); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
| 345 | 345 | if($result->city_id != $request->city_id || $result->category_id != $request->category_id){
|
| 346 | 346 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 347 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 348 | - ->where('category_id',$request->category_id)
|
|
| 349 | - ->where('city_id',$request->city_id)
|
|
| 350 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 351 | - ->orderBy('bulan')
|
|
| 352 | - ->count(); |
|
| 347 | + ->where('tanggal','like','%'.$format.'%')
|
|
| 348 | + ->where('category_id',$request->category_id)
|
|
| 349 | + ->where('city_id',$request->city_id)
|
|
| 350 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 351 | + ->orderBy('bulan')
|
|
| 352 | + ->count(); |
|
| 353 | 353 | if($resultcek > 0){
|
| 354 | - return Response::json(array( |
|
| 355 | - 'title' => 'Error', |
|
| 356 | - 'type' => 'error', |
|
| 357 | - 'message' => 'Data has already been taken.' |
|
| 358 | - )); |
|
| 354 | + return Response::json(array( |
|
| 355 | + 'title' => 'Error', |
|
| 356 | + 'type' => 'error', |
|
| 357 | + 'message' => 'Data has already been taken.' |
|
| 358 | + )); |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
@@ -363,34 +363,34 @@ discard block |
||
| 363 | 363 | $dates = date('Y-m-d', strtotime($result->tanggal));
|
| 364 | 364 | if($dates != $format){
|
| 365 | 365 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 366 | - ->where('category_id',$request->category_id)
|
|
| 367 | - ->where('city_id',$request->city_id)
|
|
| 368 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 369 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 370 | - ->orderBy('bulan')
|
|
| 371 | - ->count(); |
|
| 366 | + ->where('category_id',$request->category_id)
|
|
| 367 | + ->where('city_id',$request->city_id)
|
|
| 368 | + ->where('tanggal','like','%'.$format.'%')
|
|
| 369 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 370 | + ->orderBy('bulan')
|
|
| 371 | + ->count(); |
|
| 372 | 372 | if($resultcek > 0){
|
| 373 | - return Response::json(array( |
|
| 374 | - 'title' => 'Error', |
|
| 375 | - 'type' => 'error', |
|
| 376 | - 'message' => 'Data has already been taken.' |
|
| 377 | - )); |
|
| 373 | + return Response::json(array( |
|
| 374 | + 'title' => 'Error', |
|
| 375 | + 'type' => 'error', |
|
| 376 | + 'message' => 'Data has already been taken.' |
|
| 377 | + )); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | $data = EpormasCounter::whereNull('deleted_at')
|
| 381 | - ->where('tahun', $date[0])
|
|
| 382 | - ->where('bulan', $date[1])
|
|
| 383 | - ->where('category_id',$request->category_id)
|
|
| 384 | - ->where('city_id',$request->city_id)
|
|
| 385 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 386 | - ->orderBy('bulan')
|
|
| 387 | - ->count(); |
|
| 381 | + ->where('tahun', $date[0])
|
|
| 382 | + ->where('bulan', $date[1])
|
|
| 383 | + ->where('category_id',$request->category_id)
|
|
| 384 | + ->where('city_id',$request->city_id)
|
|
| 385 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 386 | + ->orderBy('bulan')
|
|
| 387 | + ->count(); |
|
| 388 | 388 | if($data > 0){
|
| 389 | - return Response::json(array( |
|
| 390 | - 'title' => 'Error', |
|
| 391 | - 'type' => 'error', |
|
| 392 | - 'message' => 'Data has already been taken.' |
|
| 393 | - )); |
|
| 389 | + return Response::json(array( |
|
| 390 | + 'title' => 'Error', |
|
| 391 | + 'type' => 'error', |
|
| 392 | + 'message' => 'Data has already been taken.' |
|
| 393 | + )); |
|
| 394 | 394 | } |
| 395 | 395 | } |
| 396 | 396 | |
@@ -400,13 +400,13 @@ discard block |
||
| 400 | 400 | $from = $result->via; |
| 401 | 401 | $user_id = $result->user_id; |
| 402 | 402 | if(in_array('api',$explode)){
|
| 403 | - $from = 'api'; |
|
| 404 | - $user_id = $request->user_id; |
|
| 403 | + $from = 'api'; |
|
| 404 | + $user_id = $request->user_id; |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | $via = $from; |
| 408 | 408 | if($version != '' && $version != 'update'){
|
| 409 | - $via .= '-'.$version; |
|
| 409 | + $via .= '-'.$version; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | try {
|
@@ -426,12 +426,12 @@ discard block |
||
| 426 | 426 | 'via' => $via |
| 427 | 427 | ]); |
| 428 | 428 | return Response::json(array( |
| 429 | - 'error' => $error, |
|
| 430 | - 'status' => $statusCode, |
|
| 431 | - 'title' => $title, |
|
| 432 | - 'type' => $type, |
|
| 433 | - 'message' => $message, |
|
| 434 | - 'result' => $result |
|
| 429 | + 'error' => $error, |
|
| 430 | + 'status' => $statusCode, |
|
| 431 | + 'title' => $title, |
|
| 432 | + 'type' => $type, |
|
| 433 | + 'message' => $message, |
|
| 434 | + 'result' => $result |
|
| 435 | 435 | )); |
| 436 | 436 | } catch (Exception $e) {
|
| 437 | 437 | $error = true; |
@@ -441,53 +441,53 @@ discard block |
||
| 441 | 441 | $message = 'Error'; |
| 442 | 442 | $result = 'Not Found'; |
| 443 | 443 | return Response::json(array( |
| 444 | - 'error' => $error, |
|
| 445 | - 'status' => $statusCode, |
|
| 446 | - 'title' => $title, |
|
| 447 | - 'type' => $type, |
|
| 448 | - 'message' => $message, |
|
| 449 | - 'result' => $result |
|
| 444 | + 'error' => $error, |
|
| 445 | + 'status' => $statusCode, |
|
| 446 | + 'title' => $title, |
|
| 447 | + 'type' => $type, |
|
| 448 | + 'message' => $message, |
|
| 449 | + 'result' => $result |
|
| 450 | 450 | )); |
| 451 | 451 | } |
| 452 | - } |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | - /** |
|
| 455 | - * Remove the specified resource from storage. |
|
| 456 | - * |
|
| 457 | - * @param int $id |
|
| 458 | - * @return Response |
|
| 459 | - */ |
|
| 460 | - public function destroy($id) |
|
| 461 | - {
|
|
| 462 | - try {
|
|
| 463 | - EpormasCounter::find($id)->delete(); |
|
| 464 | - $error = false; |
|
| 465 | - $statusCode = 200; |
|
| 466 | - $title = 'Success'; |
|
| 467 | - $type = 'success'; |
|
| 468 | - $message = 'Data deleted successfully'; |
|
| 469 | - return Response::json(array( |
|
| 454 | + /** |
|
| 455 | + * Remove the specified resource from storage. |
|
| 456 | + * |
|
| 457 | + * @param int $id |
|
| 458 | + * @return Response |
|
| 459 | + */ |
|
| 460 | + public function destroy($id) |
|
| 461 | + {
|
|
| 462 | + try {
|
|
| 463 | + EpormasCounter::find($id)->delete(); |
|
| 464 | + $error = false; |
|
| 465 | + $statusCode = 200; |
|
| 466 | + $title = 'Success'; |
|
| 467 | + $type = 'success'; |
|
| 468 | + $message = 'Data deleted successfully'; |
|
| 469 | + return Response::json(array( |
|
| 470 | 470 | 'error' => $error, |
| 471 | 471 | 'status' => $statusCode, |
| 472 | 472 | 'title' => $title, |
| 473 | 473 | 'type' => $type, |
| 474 | 474 | 'message' => $message |
| 475 | - )); |
|
| 476 | - } catch (Exception $e) {
|
|
| 477 | - $error = true; |
|
| 478 | - $statusCode = 404; |
|
| 479 | - $title = 'Error'; |
|
| 480 | - $type = 'error'; |
|
| 481 | - $message = 'Error'; |
|
| 482 | - return Response::json(array( |
|
| 475 | + )); |
|
| 476 | + } catch (Exception $e) {
|
|
| 477 | + $error = true; |
|
| 478 | + $statusCode = 404; |
|
| 479 | + $title = 'Error'; |
|
| 480 | + $type = 'error'; |
|
| 481 | + $message = 'Error'; |
|
| 482 | + return Response::json(array( |
|
| 483 | 483 | 'error' => $error, |
| 484 | 484 | 'status' => $statusCode, |
| 485 | 485 | 'title' => $title, |
| 486 | 486 | 'type' => $type, |
| 487 | 487 | 'message' => $message |
| 488 | - )); |
|
| 489 | - } |
|
| 490 | - } |
|
| 488 | + )); |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | 491 | |
| 492 | 492 | } |
| 493 | 493 | |
@@ -106,18 +106,18 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return Response |
| 108 | 108 | */ |
| 109 | - public function store(Request $request, $version='') |
|
| 109 | + public function store(Request $request, $version = '') |
|
| 110 | 110 | {
|
| 111 | 111 | $path = \Request::path(); |
| 112 | 112 | $explode = explode('/', $path);
|
| 113 | 113 | |
| 114 | 114 | $from = 'form'; |
| 115 | - if(in_array('api',$explode)){
|
|
| 115 | + if (in_array('api', $explode)) {
|
|
| 116 | 116 | $from = 'api'; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $via = $from; |
| 120 | - if($version != '' && $version != 'store'){
|
|
| 120 | + if ($version != '' && $version != 'store') {
|
|
| 121 | 121 | $via .= '-'.$version; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -137,15 +137,15 @@ discard block |
||
| 137 | 137 | )); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
|
| 140 | + $format = date('Y-m-d', strtotime(str_replace(' ', '-', $request->tanggal)));
|
|
| 141 | 141 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 142 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 143 | - ->where('category_id',$request->category_id)
|
|
| 144 | - ->where('city_id',$request->city_id)
|
|
| 145 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 142 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 143 | + ->where('category_id', $request->category_id)
|
|
| 144 | + ->where('city_id', $request->city_id)
|
|
| 145 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 146 | 146 | ->orderBy('bulan')
|
| 147 | 147 | ->count(); |
| 148 | - if($resultcek > 0){
|
|
| 148 | + if ($resultcek > 0) {
|
|
| 149 | 149 | return Response::json(array( |
| 150 | 150 | 'title' => 'Error', |
| 151 | 151 | 'type' => 'error', |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | )); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $date = explode("-",$format);
|
|
| 156 | + $date = explode("-", $format);
|
|
| 157 | 157 | $data = EpormasCounter::whereNull('deleted_at')
|
| 158 | 158 | ->where('tahun', $date[0])
|
| 159 | 159 | ->where('bulan', $date[1])
|
| 160 | - ->where('category_id',$request->category_id)
|
|
| 161 | - ->where('city_id',$request->city_id)
|
|
| 162 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 160 | + ->where('category_id', $request->category_id)
|
|
| 161 | + ->where('city_id', $request->city_id)
|
|
| 162 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 163 | 163 | ->orderBy('bulan')
|
| 164 | 164 | ->count(); |
| 165 | - if($data > 0){
|
|
| 165 | + if ($data > 0) {
|
|
| 166 | 166 | return Response::json(array( |
| 167 | 167 | 'title' => 'Error', |
| 168 | 168 | 'type' => 'error', |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param int $id |
| 219 | 219 | * @return Response |
| 220 | 220 | */ |
| 221 | - public function show($version='', $id) |
|
| 221 | + public function show($version = '', $id) |
|
| 222 | 222 | {
|
| 223 | 223 | try {
|
| 224 | 224 | $error = false; |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * @param int $id |
| 319 | 319 | * @return Response |
| 320 | 320 | */ |
| 321 | - public function update(Request $request, $version='', $id) |
|
| 321 | + public function update(Request $request, $version = '', $id) |
|
| 322 | 322 | {
|
| 323 | 323 | $result = EpormasCounter::whereNull('deleted_at')
|
| 324 | 324 | ->with('getCity')
|
@@ -341,16 +341,16 @@ discard block |
||
| 341 | 341 | )); |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
|
| 345 | - if($result->city_id != $request->city_id || $result->category_id != $request->category_id){
|
|
| 344 | + $format = date('Y-m-d', strtotime(str_replace(' ', '-', $request->tanggal)));
|
|
| 345 | + if ($result->city_id != $request->city_id || $result->category_id != $request->category_id) {
|
|
| 346 | 346 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 347 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 348 | - ->where('category_id',$request->category_id)
|
|
| 349 | - ->where('city_id',$request->city_id)
|
|
| 350 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 347 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 348 | + ->where('category_id', $request->category_id)
|
|
| 349 | + ->where('city_id', $request->city_id)
|
|
| 350 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 351 | 351 | ->orderBy('bulan')
|
| 352 | 352 | ->count(); |
| 353 | - if($resultcek > 0){
|
|
| 353 | + if ($resultcek > 0) {
|
|
| 354 | 354 | return Response::json(array( |
| 355 | 355 | 'title' => 'Error', |
| 356 | 356 | 'type' => 'error', |
@@ -359,17 +359,17 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $date = explode("-",$format);
|
|
| 362 | + $date = explode("-", $format);
|
|
| 363 | 363 | $dates = date('Y-m-d', strtotime($result->tanggal));
|
| 364 | - if($dates != $format){
|
|
| 364 | + if ($dates != $format) {
|
|
| 365 | 365 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 366 | - ->where('category_id',$request->category_id)
|
|
| 367 | - ->where('city_id',$request->city_id)
|
|
| 368 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 369 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 366 | + ->where('category_id', $request->category_id)
|
|
| 367 | + ->where('city_id', $request->city_id)
|
|
| 368 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 369 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 370 | 370 | ->orderBy('bulan')
|
| 371 | 371 | ->count(); |
| 372 | - if($resultcek > 0){
|
|
| 372 | + if ($resultcek > 0) {
|
|
| 373 | 373 | return Response::json(array( |
| 374 | 374 | 'title' => 'Error', |
| 375 | 375 | 'type' => 'error', |
@@ -380,12 +380,12 @@ discard block |
||
| 380 | 380 | $data = EpormasCounter::whereNull('deleted_at')
|
| 381 | 381 | ->where('tahun', $date[0])
|
| 382 | 382 | ->where('bulan', $date[1])
|
| 383 | - ->where('category_id',$request->category_id)
|
|
| 384 | - ->where('city_id',$request->city_id)
|
|
| 385 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 383 | + ->where('category_id', $request->category_id)
|
|
| 384 | + ->where('city_id', $request->city_id)
|
|
| 385 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 386 | 386 | ->orderBy('bulan')
|
| 387 | 387 | ->count(); |
| 388 | - if($data > 0){
|
|
| 388 | + if ($data > 0) {
|
|
| 389 | 389 | return Response::json(array( |
| 390 | 390 | 'title' => 'Error', |
| 391 | 391 | 'type' => 'error', |
@@ -399,13 +399,13 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | $from = $result->via; |
| 401 | 401 | $user_id = $result->user_id; |
| 402 | - if(in_array('api',$explode)){
|
|
| 402 | + if (in_array('api', $explode)) {
|
|
| 403 | 403 | $from = 'api'; |
| 404 | 404 | $user_id = $request->user_id; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | $via = $from; |
| 408 | - if($version != '' && $version != 'update'){
|
|
| 408 | + if ($version != '' && $version != 'update') {
|
|
| 409 | 409 | $via .= '-'.$version; |
| 410 | 410 | } |
| 411 | 411 | |
@@ -12,98 +12,98 @@ discard block |
||
| 12 | 12 | class EpormasCityController extends Controller |
| 13 | 13 | {
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Display a listing of the resource. |
|
| 17 | - * |
|
| 18 | - * @return Response |
|
| 19 | - */ |
|
| 20 | - public function index() |
|
| 21 | - {
|
|
| 22 | - try {
|
|
| 23 | - $error = false; |
|
| 24 | - $statusCode = 200; |
|
| 25 | - $title = 'Success'; |
|
| 26 | - $type = 'success'; |
|
| 27 | - $message = 'Success'; |
|
| 28 | - $result = EpormasCity::all(); |
|
| 29 | - return Response::json(array( |
|
| 15 | + /** |
|
| 16 | + * Display a listing of the resource. |
|
| 17 | + * |
|
| 18 | + * @return Response |
|
| 19 | + */ |
|
| 20 | + public function index() |
|
| 21 | + {
|
|
| 22 | + try {
|
|
| 23 | + $error = false; |
|
| 24 | + $statusCode = 200; |
|
| 25 | + $title = 'Success'; |
|
| 26 | + $type = 'success'; |
|
| 27 | + $message = 'Success'; |
|
| 28 | + $result = EpormasCity::all(); |
|
| 29 | + return Response::json(array( |
|
| 30 | 30 | 'error' => $error, |
| 31 | 31 | 'status' => $statusCode, |
| 32 | 32 | 'title' => $title, |
| 33 | 33 | 'type' => $type, |
| 34 | 34 | 'message' => $message, |
| 35 | 35 | 'result' => $result |
| 36 | - )); |
|
| 37 | - } catch (Exception $e) {
|
|
| 38 | - $error = true; |
|
| 39 | - $statusCode = 404; |
|
| 40 | - $title = 'Error'; |
|
| 41 | - $type = 'error'; |
|
| 42 | - $message = 'Error'; |
|
| 43 | - $result = 'Not Found'; |
|
| 44 | - return Response::json(array( |
|
| 36 | + )); |
|
| 37 | + } catch (Exception $e) {
|
|
| 38 | + $error = true; |
|
| 39 | + $statusCode = 404; |
|
| 40 | + $title = 'Error'; |
|
| 41 | + $type = 'error'; |
|
| 42 | + $message = 'Error'; |
|
| 43 | + $result = 'Not Found'; |
|
| 44 | + return Response::json(array( |
|
| 45 | 45 | 'error' => $error, |
| 46 | 46 | 'status' => $statusCode, |
| 47 | 47 | 'title' => $title, |
| 48 | 48 | 'type' => $type, |
| 49 | 49 | 'message' => $message, |
| 50 | 50 | 'result' => $result |
| 51 | - )); |
|
| 52 | - } |
|
| 53 | - } |
|
| 51 | + )); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Show the form for creating a new resource. |
|
| 57 | - * |
|
| 58 | - * @return Response |
|
| 59 | - */ |
|
| 60 | - public function create() |
|
| 61 | - {
|
|
| 55 | + /** |
|
| 56 | + * Show the form for creating a new resource. |
|
| 57 | + * |
|
| 58 | + * @return Response |
|
| 59 | + */ |
|
| 60 | + public function create() |
|
| 61 | + {
|
|
| 62 | 62 | |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Store a newly created resource in storage. |
|
| 67 | - * |
|
| 68 | - * @return Response |
|
| 69 | - */ |
|
| 70 | - public function store(Request $request, $version='') |
|
| 71 | - {
|
|
| 65 | + /** |
|
| 66 | + * Store a newly created resource in storage. |
|
| 67 | + * |
|
| 68 | + * @return Response |
|
| 69 | + */ |
|
| 70 | + public function store(Request $request, $version='') |
|
| 71 | + {
|
|
| 72 | 72 | $path = \Request::path(); |
| 73 | 73 | $explode = explode('/', $path);
|
| 74 | 74 | |
| 75 | 75 | $from = 'form'; |
| 76 | 76 | if(in_array('api',$explode)){
|
| 77 | - $from = 'api'; |
|
| 77 | + $from = 'api'; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $via = $from; |
| 81 | 81 | if($version != '' && $version != 'store'){
|
| 82 | - $via .= '-'.$version; |
|
| 82 | + $via .= '-'.$version; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $rules = [ |
|
| 85 | + $rules = [ |
|
| 86 | 86 | 'name' => 'required' |
| 87 | 87 | ]; |
| 88 | 88 | |
| 89 | 89 | $validator = Validator::make($request->all(), $rules); |
| 90 | 90 | if ($validator->fails()) {
|
| 91 | - return Response::json(array( |
|
| 92 | - 'title' => 'Error', |
|
| 93 | - 'type' => 'error', |
|
| 94 | - 'message' => $validator->errors()->all() |
|
| 95 | - )); |
|
| 91 | + return Response::json(array( |
|
| 92 | + 'title' => 'Error', |
|
| 93 | + 'type' => 'error', |
|
| 94 | + 'message' => $validator->errors()->all() |
|
| 95 | + )); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | $data = EpormasCity::whereNull('deleted_at')
|
| 99 | 99 | ->where('name', $request->name)
|
| 100 | 100 | ->count(); |
| 101 | 101 | if($data > 0){
|
| 102 | - return Response::json(array( |
|
| 103 | - 'title' => 'Error', |
|
| 104 | - 'type' => 'error', |
|
| 105 | - 'message' => 'Data has already been taken.' |
|
| 106 | - )); |
|
| 102 | + return Response::json(array( |
|
| 103 | + 'title' => 'Error', |
|
| 104 | + 'type' => 'error', |
|
| 105 | + 'message' => 'Data has already been taken.' |
|
| 106 | + )); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | try {
|
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | 'name' => $request->name |
| 117 | 117 | ]); |
| 118 | 118 | return Response::json(array( |
| 119 | - 'error' => $error, |
|
| 120 | - 'status' => $statusCode, |
|
| 121 | - 'title' => $title, |
|
| 122 | - 'type' => $type, |
|
| 123 | - 'message' => $message, |
|
| 124 | - 'result' => $result |
|
| 119 | + 'error' => $error, |
|
| 120 | + 'status' => $statusCode, |
|
| 121 | + 'title' => $title, |
|
| 122 | + 'type' => $type, |
|
| 123 | + 'message' => $message, |
|
| 124 | + 'result' => $result |
|
| 125 | 125 | )); |
| 126 | 126 | } catch (Exception $e) {
|
| 127 | 127 | $error = true; |
@@ -131,24 +131,24 @@ discard block |
||
| 131 | 131 | $message = 'Error'; |
| 132 | 132 | $result = 'Not Found'; |
| 133 | 133 | return Response::json(array( |
| 134 | - 'error' => $error, |
|
| 135 | - 'status' => $statusCode, |
|
| 136 | - 'title' => $title, |
|
| 137 | - 'type' => $type, |
|
| 138 | - 'message' => $message, |
|
| 139 | - 'result' => $result |
|
| 134 | + 'error' => $error, |
|
| 135 | + 'status' => $statusCode, |
|
| 136 | + 'title' => $title, |
|
| 137 | + 'type' => $type, |
|
| 138 | + 'message' => $message, |
|
| 139 | + 'result' => $result |
|
| 140 | 140 | )); |
| 141 | 141 | } |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * Display the specified resource. |
|
| 146 | - * |
|
| 147 | - * @param int $id |
|
| 148 | - * @return Response |
|
| 149 | - */ |
|
| 150 | - public function show($version='', $id) |
|
| 151 | - {
|
|
| 144 | + /** |
|
| 145 | + * Display the specified resource. |
|
| 146 | + * |
|
| 147 | + * @param int $id |
|
| 148 | + * @return Response |
|
| 149 | + */ |
|
| 150 | + public function show($version='', $id) |
|
| 151 | + {
|
|
| 152 | 152 | try {
|
| 153 | 153 | $error = false; |
| 154 | 154 | $statusCode = 200; |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | $message = 'Success'; |
| 158 | 158 | $result = EpormasCity::findOrFail($id); |
| 159 | 159 | return Response::json(array( |
| 160 | - 'error' => $error, |
|
| 161 | - 'status' => $statusCode, |
|
| 162 | - 'title' => $title, |
|
| 163 | - 'type' => $type, |
|
| 164 | - 'message' => $message, |
|
| 165 | - 'result' => $result |
|
| 160 | + 'error' => $error, |
|
| 161 | + 'status' => $statusCode, |
|
| 162 | + 'title' => $title, |
|
| 163 | + 'type' => $type, |
|
| 164 | + 'message' => $message, |
|
| 165 | + 'result' => $result |
|
| 166 | 166 | )); |
| 167 | 167 | } catch (Exception $e) {
|
| 168 | 168 | $error = true; |
@@ -172,24 +172,24 @@ discard block |
||
| 172 | 172 | $message = 'Error'; |
| 173 | 173 | $result = 'Not Found'; |
| 174 | 174 | return Response::json(array( |
| 175 | - 'error' => $error, |
|
| 176 | - 'status' => $statusCode, |
|
| 177 | - 'title' => $title, |
|
| 178 | - 'type' => $type, |
|
| 179 | - 'message' => $message, |
|
| 180 | - 'result' => $result |
|
| 175 | + 'error' => $error, |
|
| 176 | + 'status' => $statusCode, |
|
| 177 | + 'title' => $title, |
|
| 178 | + 'type' => $type, |
|
| 179 | + 'message' => $message, |
|
| 180 | + 'result' => $result |
|
| 181 | 181 | )); |
| 182 | 182 | } |
| 183 | - } |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Show the form for editing the specified resource. |
|
| 187 | - * |
|
| 188 | - * @param int $id |
|
| 189 | - * @return Response |
|
| 190 | - */ |
|
| 191 | - public function edit($id) |
|
| 192 | - {
|
|
| 185 | + /** |
|
| 186 | + * Show the form for editing the specified resource. |
|
| 187 | + * |
|
| 188 | + * @param int $id |
|
| 189 | + * @return Response |
|
| 190 | + */ |
|
| 191 | + public function edit($id) |
|
| 192 | + {
|
|
| 193 | 193 | try {
|
| 194 | 194 | $error = false; |
| 195 | 195 | $statusCode = 200; |
@@ -198,12 +198,12 @@ discard block |
||
| 198 | 198 | $message = 'Success'; |
| 199 | 199 | $result = EpormasCity::findOrFail($id); |
| 200 | 200 | return Response::json(array( |
| 201 | - 'error' => $error, |
|
| 202 | - 'status' => $statusCode, |
|
| 203 | - 'title' => $title, |
|
| 204 | - 'type' => $type, |
|
| 205 | - 'message' => $message, |
|
| 206 | - 'result' => $result |
|
| 201 | + 'error' => $error, |
|
| 202 | + 'status' => $statusCode, |
|
| 203 | + 'title' => $title, |
|
| 204 | + 'type' => $type, |
|
| 205 | + 'message' => $message, |
|
| 206 | + 'result' => $result |
|
| 207 | 207 | )); |
| 208 | 208 | } catch (Exception $e) {
|
| 209 | 209 | $error = true; |
@@ -213,24 +213,24 @@ discard block |
||
| 213 | 213 | $message = 'Error'; |
| 214 | 214 | $result = 'Not Found'; |
| 215 | 215 | return Response::json(array( |
| 216 | - 'error' => $error, |
|
| 217 | - 'status' => $statusCode, |
|
| 218 | - 'title' => $title, |
|
| 219 | - 'type' => $type, |
|
| 220 | - 'message' => $message, |
|
| 221 | - 'result' => $result |
|
| 216 | + 'error' => $error, |
|
| 217 | + 'status' => $statusCode, |
|
| 218 | + 'title' => $title, |
|
| 219 | + 'type' => $type, |
|
| 220 | + 'message' => $message, |
|
| 221 | + 'result' => $result |
|
| 222 | 222 | )); |
| 223 | 223 | } |
| 224 | - } |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Update the specified resource in storage. |
|
| 228 | - * |
|
| 229 | - * @param int $id |
|
| 230 | - * @return Response |
|
| 231 | - */ |
|
| 232 | - public function update(Request $request, $version='', $id) |
|
| 233 | - {
|
|
| 226 | + /** |
|
| 227 | + * Update the specified resource in storage. |
|
| 228 | + * |
|
| 229 | + * @param int $id |
|
| 230 | + * @return Response |
|
| 231 | + */ |
|
| 232 | + public function update(Request $request, $version='', $id) |
|
| 233 | + {
|
|
| 234 | 234 | $result = EpormasCity::find($id); |
| 235 | 235 | |
| 236 | 236 | $rules = [ |
@@ -239,24 +239,24 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | $validator = Validator::make($request->all(), $rules); |
| 241 | 241 | if ($validator->fails()) {
|
| 242 | - return Response::json(array( |
|
| 243 | - 'title' => 'Error', |
|
| 244 | - 'type' => 'error', |
|
| 245 | - 'message' => $validator->errors()->all() |
|
| 246 | - )); |
|
| 242 | + return Response::json(array( |
|
| 243 | + 'title' => 'Error', |
|
| 244 | + 'type' => 'error', |
|
| 245 | + 'message' => $validator->errors()->all() |
|
| 246 | + )); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | if($request->name != $result->name){
|
| 250 | - $data = EpormasCity::whereNull('deleted_at')
|
|
| 251 | - ->where('name', $request->name)
|
|
| 252 | - ->count(); |
|
| 253 | - if($data > 0){
|
|
| 250 | + $data = EpormasCity::whereNull('deleted_at')
|
|
| 251 | + ->where('name', $request->name)
|
|
| 252 | + ->count(); |
|
| 253 | + if($data > 0){
|
|
| 254 | 254 | return Response::json(array( |
| 255 | 255 | 'title' => 'Error', |
| 256 | 256 | 'type' => 'error', |
| 257 | 257 | 'message' => 'Data has already been taken.' |
| 258 | 258 | )); |
| 259 | - } |
|
| 259 | + } |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $path = \Request::path(); |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | $from = 'form'; |
| 266 | 266 | if(in_array('api',$explode)){
|
| 267 | - $from = 'api'; |
|
| 267 | + $from = 'api'; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | $via = $from; |
| 271 | 271 | if($version != '' && $version != 'update'){
|
| 272 | - $via .= '-'.$version; |
|
| 272 | + $via .= '-'.$version; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | try {
|
@@ -282,12 +282,12 @@ discard block |
||
| 282 | 282 | 'name' => $request->name |
| 283 | 283 | ]); |
| 284 | 284 | return Response::json(array( |
| 285 | - 'error' => $error, |
|
| 286 | - 'status' => $statusCode, |
|
| 287 | - 'title' => $title, |
|
| 288 | - 'type' => $type, |
|
| 289 | - 'message' => $message, |
|
| 290 | - 'result' => $result |
|
| 285 | + 'error' => $error, |
|
| 286 | + 'status' => $statusCode, |
|
| 287 | + 'title' => $title, |
|
| 288 | + 'type' => $type, |
|
| 289 | + 'message' => $message, |
|
| 290 | + 'result' => $result |
|
| 291 | 291 | )); |
| 292 | 292 | } catch (Exception $e) {
|
| 293 | 293 | $error = true; |
@@ -297,53 +297,53 @@ discard block |
||
| 297 | 297 | $message = 'Error'; |
| 298 | 298 | $result = 'Not Found'; |
| 299 | 299 | return Response::json(array( |
| 300 | - 'error' => $error, |
|
| 301 | - 'status' => $statusCode, |
|
| 302 | - 'title' => $title, |
|
| 303 | - 'type' => $type, |
|
| 304 | - 'message' => $message, |
|
| 305 | - 'result' => $result |
|
| 300 | + 'error' => $error, |
|
| 301 | + 'status' => $statusCode, |
|
| 302 | + 'title' => $title, |
|
| 303 | + 'type' => $type, |
|
| 304 | + 'message' => $message, |
|
| 305 | + 'result' => $result |
|
| 306 | 306 | )); |
| 307 | 307 | } |
| 308 | - } |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - /** |
|
| 311 | - * Remove the specified resource from storage. |
|
| 312 | - * |
|
| 313 | - * @param int $id |
|
| 314 | - * @return Response |
|
| 315 | - */ |
|
| 316 | - public function destroy($id) |
|
| 317 | - {
|
|
| 318 | - try {
|
|
| 319 | - EpormasCity::find($id)->delete(); |
|
| 320 | - $error = false; |
|
| 321 | - $statusCode = 200; |
|
| 322 | - $title = 'Success'; |
|
| 323 | - $type = 'success'; |
|
| 324 | - $message = 'Data deleted successfully'; |
|
| 325 | - return Response::json(array( |
|
| 310 | + /** |
|
| 311 | + * Remove the specified resource from storage. |
|
| 312 | + * |
|
| 313 | + * @param int $id |
|
| 314 | + * @return Response |
|
| 315 | + */ |
|
| 316 | + public function destroy($id) |
|
| 317 | + {
|
|
| 318 | + try {
|
|
| 319 | + EpormasCity::find($id)->delete(); |
|
| 320 | + $error = false; |
|
| 321 | + $statusCode = 200; |
|
| 322 | + $title = 'Success'; |
|
| 323 | + $type = 'success'; |
|
| 324 | + $message = 'Data deleted successfully'; |
|
| 325 | + return Response::json(array( |
|
| 326 | 326 | 'error' => $error, |
| 327 | 327 | 'status' => $statusCode, |
| 328 | 328 | 'title' => $title, |
| 329 | 329 | 'type' => $type, |
| 330 | 330 | 'message' => $message |
| 331 | - )); |
|
| 332 | - } catch (Exception $e) {
|
|
| 333 | - $error = true; |
|
| 334 | - $statusCode = 404; |
|
| 335 | - $title = 'Error'; |
|
| 336 | - $type = 'error'; |
|
| 337 | - $message = 'Error'; |
|
| 338 | - return Response::json(array( |
|
| 331 | + )); |
|
| 332 | + } catch (Exception $e) {
|
|
| 333 | + $error = true; |
|
| 334 | + $statusCode = 404; |
|
| 335 | + $title = 'Error'; |
|
| 336 | + $type = 'error'; |
|
| 337 | + $message = 'Error'; |
|
| 338 | + return Response::json(array( |
|
| 339 | 339 | 'error' => $error, |
| 340 | 340 | 'status' => $statusCode, |
| 341 | 341 | 'title' => $title, |
| 342 | 342 | 'type' => $type, |
| 343 | 343 | 'message' => $message |
| 344 | - )); |
|
| 345 | - } |
|
| 346 | - } |
|
| 344 | + )); |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | 348 | } |
| 349 | 349 | |
@@ -67,18 +67,18 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return Response |
| 69 | 69 | */ |
| 70 | - public function store(Request $request, $version='') |
|
| 70 | + public function store(Request $request, $version = '') |
|
| 71 | 71 | {
|
| 72 | 72 | $path = \Request::path(); |
| 73 | 73 | $explode = explode('/', $path);
|
| 74 | 74 | |
| 75 | 75 | $from = 'form'; |
| 76 | - if(in_array('api',$explode)){
|
|
| 76 | + if (in_array('api', $explode)) {
|
|
| 77 | 77 | $from = 'api'; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $via = $from; |
| 81 | - if($version != '' && $version != 'store'){
|
|
| 81 | + if ($version != '' && $version != 'store') {
|
|
| 82 | 82 | $via .= '-'.$version; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $data = EpormasCity::whereNull('deleted_at')
|
| 99 | 99 | ->where('name', $request->name)
|
| 100 | 100 | ->count(); |
| 101 | - if($data > 0){
|
|
| 101 | + if ($data > 0) {
|
|
| 102 | 102 | return Response::json(array( |
| 103 | 103 | 'title' => 'Error', |
| 104 | 104 | 'type' => 'error', |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param int $id |
| 148 | 148 | * @return Response |
| 149 | 149 | */ |
| 150 | - public function show($version='', $id) |
|
| 150 | + public function show($version = '', $id) |
|
| 151 | 151 | {
|
| 152 | 152 | try {
|
| 153 | 153 | $error = false; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param int $id |
| 230 | 230 | * @return Response |
| 231 | 231 | */ |
| 232 | - public function update(Request $request, $version='', $id) |
|
| 232 | + public function update(Request $request, $version = '', $id) |
|
| 233 | 233 | {
|
| 234 | 234 | $result = EpormasCity::find($id); |
| 235 | 235 | |
@@ -246,11 +246,11 @@ discard block |
||
| 246 | 246 | )); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if($request->name != $result->name){
|
|
| 249 | + if ($request->name != $result->name) {
|
|
| 250 | 250 | $data = EpormasCity::whereNull('deleted_at')
|
| 251 | 251 | ->where('name', $request->name)
|
| 252 | 252 | ->count(); |
| 253 | - if($data > 0){
|
|
| 253 | + if ($data > 0) {
|
|
| 254 | 254 | return Response::json(array( |
| 255 | 255 | 'title' => 'Error', |
| 256 | 256 | 'type' => 'error', |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | $explode = explode('/', $path);
|
| 264 | 264 | |
| 265 | 265 | $from = 'form'; |
| 266 | - if(in_array('api',$explode)){
|
|
| 266 | + if (in_array('api', $explode)) {
|
|
| 267 | 267 | $from = 'api'; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | $via = $from; |
| 271 | - if($version != '' && $version != 'update'){
|
|
| 271 | + if ($version != '' && $version != 'update') {
|
|
| 272 | 272 | $via .= '-'.$version; |
| 273 | 273 | } |
| 274 | 274 | |