@@ -14,67 +14,67 @@ 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 | - } catch (Exception $e) {
|
|
| 35 | - $error = true; |
|
| 36 | - $statusCode = 404; |
|
| 37 | - $title = 'Error'; |
|
| 38 | - $type = 'error'; |
|
| 39 | - $message = 'Error'; |
|
| 40 | - $result = 'Not Found'; |
|
| 41 | - } finally {
|
|
| 42 | - 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 | + } catch (Exception $e) {
|
|
| 35 | + $error = true; |
|
| 36 | + $statusCode = 404; |
|
| 37 | + $title = 'Error'; |
|
| 38 | + $type = 'error'; |
|
| 39 | + $message = 'Error'; |
|
| 40 | + $result = 'Not Found'; |
|
| 41 | + } finally {
|
|
| 42 | + return Response::json(array( |
|
| 43 | 43 | 'error' => $error, |
| 44 | 44 | 'status' => $statusCode, |
| 45 | 45 | 'title' => $title, |
| 46 | 46 | 'type' => $type, |
| 47 | 47 | 'message' => $message, |
| 48 | 48 | 'result' => $result |
| 49 | - )); |
|
| 50 | - } |
|
| 51 | - } |
|
| 49 | + )); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Show the form for creating a new resource. |
|
| 55 | - * |
|
| 56 | - * @return Response |
|
| 57 | - */ |
|
| 58 | - public function create() |
|
| 59 | - {
|
|
| 60 | - try {
|
|
| 61 | - $error = false; |
|
| 62 | - $statusCode = 200; |
|
| 63 | - $title = 'Success'; |
|
| 64 | - $type = 'success'; |
|
| 65 | - $message = 'Success'; |
|
| 66 | - $city = EpormasCity::all(); |
|
| 67 | - $category = EpormasCategory::all(); |
|
| 68 | - } catch (Exception $e) {
|
|
| 69 | - $error = true; |
|
| 70 | - $statusCode = 404; |
|
| 71 | - $title = 'Error'; |
|
| 72 | - $type = 'error'; |
|
| 73 | - $message = 'Error'; |
|
| 74 | - $city = 'Not Found'; |
|
| 75 | - $category = 'Not Found'; |
|
| 76 | - } finally {
|
|
| 77 | - return Response::json(array( |
|
| 53 | + /** |
|
| 54 | + * Show the form for creating a new resource. |
|
| 55 | + * |
|
| 56 | + * @return Response |
|
| 57 | + */ |
|
| 58 | + public function create() |
|
| 59 | + {
|
|
| 60 | + try {
|
|
| 61 | + $error = false; |
|
| 62 | + $statusCode = 200; |
|
| 63 | + $title = 'Success'; |
|
| 64 | + $type = 'success'; |
|
| 65 | + $message = 'Success'; |
|
| 66 | + $city = EpormasCity::all(); |
|
| 67 | + $category = EpormasCategory::all(); |
|
| 68 | + } catch (Exception $e) {
|
|
| 69 | + $error = true; |
|
| 70 | + $statusCode = 404; |
|
| 71 | + $title = 'Error'; |
|
| 72 | + $type = 'error'; |
|
| 73 | + $message = 'Error'; |
|
| 74 | + $city = 'Not Found'; |
|
| 75 | + $category = 'Not Found'; |
|
| 76 | + } finally {
|
|
| 77 | + return Response::json(array( |
|
| 78 | 78 | 'error' => $error, |
| 79 | 79 | 'status' => $statusCode, |
| 80 | 80 | 'title' => $title, |
@@ -82,31 +82,31 @@ discard block |
||
| 82 | 82 | 'message' => $message, |
| 83 | 83 | 'city' => $city, |
| 84 | 84 | 'category' => $category |
| 85 | - )); |
|
| 86 | - } |
|
| 87 | - } |
|
| 85 | + )); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Store a newly created resource in storage. |
|
| 91 | - * |
|
| 92 | - * @return Response |
|
| 93 | - */ |
|
| 94 | - public function store(Request $request, $version='') |
|
| 95 | - {
|
|
| 89 | + /** |
|
| 90 | + * Store a newly created resource in storage. |
|
| 91 | + * |
|
| 92 | + * @return Response |
|
| 93 | + */ |
|
| 94 | + public function store(Request $request, $version='') |
|
| 95 | + {
|
|
| 96 | 96 | $path = \Request::path(); |
| 97 | 97 | $explode = explode('/', $path);
|
| 98 | 98 | |
| 99 | 99 | $from = 'form'; |
| 100 | 100 | if(in_array('api',$explode)){
|
| 101 | - $from = 'api'; |
|
| 101 | + $from = 'api'; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | $via = $from; |
| 105 | 105 | if($version != '' && $version != 'store'){
|
| 106 | - $via .= '-'.$version; |
|
| 106 | + $via .= '-'.$version; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $rules = [ |
|
| 109 | + $rules = [ |
|
| 110 | 110 | 'count' => 'required|numeric', |
| 111 | 111 | 'city_id' => 'required|numeric', |
| 112 | 112 | 'category_id' => 'required|numeric', |
@@ -115,44 +115,44 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $validator = Validator::make($request->all(), $rules); |
| 117 | 117 | if ($validator->fails()) {
|
| 118 | - return response()->json([ |
|
| 119 | - 'title' => 'Error', |
|
| 120 | - 'type' => 'error', |
|
| 121 | - 'message' => $validator->errors()->all() |
|
| 122 | - ]); |
|
| 118 | + return response()->json([ |
|
| 119 | + 'title' => 'Error', |
|
| 120 | + 'type' => 'error', |
|
| 121 | + 'message' => $validator->errors()->all() |
|
| 122 | + ]); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
| 126 | 126 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 127 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 128 | - ->where('category_id',$request->category_id)
|
|
| 129 | - ->where('city_id',$request->city_id)
|
|
| 130 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 131 | - ->orderBy('bulan')
|
|
| 132 | - ->count(); |
|
| 127 | + ->where('tanggal','like','%'.$format.'%')
|
|
| 128 | + ->where('category_id',$request->category_id)
|
|
| 129 | + ->where('city_id',$request->city_id)
|
|
| 130 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 131 | + ->orderBy('bulan')
|
|
| 132 | + ->count(); |
|
| 133 | 133 | if($resultcek > 0){
|
| 134 | - return response()->json([ |
|
| 135 | - 'title' => 'Error', |
|
| 136 | - 'type' => 'error', |
|
| 137 | - 'message' => 'Data has already been taken.' |
|
| 138 | - ]); |
|
| 134 | + return response()->json([ |
|
| 135 | + 'title' => 'Error', |
|
| 136 | + 'type' => 'error', |
|
| 137 | + 'message' => 'Data has already been taken.' |
|
| 138 | + ]); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $date = explode("-",$format);
|
| 142 | 142 | $data = EpormasCounter::whereNull('deleted_at')
|
| 143 | - ->where('tahun', $date[0])
|
|
| 144 | - ->where('bulan', $date[1])
|
|
| 145 | - ->where('category_id',$request->category_id)
|
|
| 146 | - ->where('city_id',$request->city_id)
|
|
| 147 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 148 | - ->orderBy('bulan')
|
|
| 149 | - ->count(); |
|
| 143 | + ->where('tahun', $date[0])
|
|
| 144 | + ->where('bulan', $date[1])
|
|
| 145 | + ->where('category_id',$request->category_id)
|
|
| 146 | + ->where('city_id',$request->city_id)
|
|
| 147 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 148 | + ->orderBy('bulan')
|
|
| 149 | + ->count(); |
|
| 150 | 150 | if($data > 0){
|
| 151 | - return response()->json([ |
|
| 152 | - 'title' => 'Error', |
|
| 153 | - 'type' => 'error', |
|
| 154 | - 'message' => 'Data has already been taken.' |
|
| 155 | - ]); |
|
| 151 | + return response()->json([ |
|
| 152 | + 'title' => 'Error', |
|
| 153 | + 'type' => 'error', |
|
| 154 | + 'message' => 'Data has already been taken.' |
|
| 155 | + ]); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | try {
|
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | $result = 'Not Found'; |
| 181 | 181 | } finally {
|
| 182 | 182 | return Response::json(array( |
| 183 | - 'error' => $error, |
|
| 184 | - 'status' => $statusCode, |
|
| 185 | - 'title' => $title, |
|
| 186 | - 'type' => $type, |
|
| 187 | - 'message' => $message, |
|
| 188 | - 'result' => $result |
|
| 183 | + 'error' => $error, |
|
| 184 | + 'status' => $statusCode, |
|
| 185 | + 'title' => $title, |
|
| 186 | + 'type' => $type, |
|
| 187 | + 'message' => $message, |
|
| 188 | + 'result' => $result |
|
| 189 | 189 | )); |
| 190 | 190 | } |
| 191 | - } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Display the specified resource. |
|
| 195 | - * |
|
| 196 | - * @param int $id |
|
| 197 | - * @return Response |
|
| 198 | - */ |
|
| 199 | - public function show($version='', $id) |
|
| 200 | - {
|
|
| 193 | + /** |
|
| 194 | + * Display the specified resource. |
|
| 195 | + * |
|
| 196 | + * @param int $id |
|
| 197 | + * @return Response |
|
| 198 | + */ |
|
| 199 | + public function show($version='', $id) |
|
| 200 | + {
|
|
| 201 | 201 | try {
|
| 202 | 202 | $error = false; |
| 203 | 203 | $statusCode = 200; |
@@ -217,24 +217,24 @@ discard block |
||
| 217 | 217 | $result = 'Not Found'; |
| 218 | 218 | } finally {
|
| 219 | 219 | return Response::json(array( |
| 220 | - 'error' => $error, |
|
| 221 | - 'status' => $statusCode, |
|
| 222 | - 'title' => $title, |
|
| 223 | - 'type' => $type, |
|
| 224 | - 'message' => $message, |
|
| 225 | - 'result' => $result |
|
| 220 | + 'error' => $error, |
|
| 221 | + 'status' => $statusCode, |
|
| 222 | + 'title' => $title, |
|
| 223 | + 'type' => $type, |
|
| 224 | + 'message' => $message, |
|
| 225 | + 'result' => $result |
|
| 226 | 226 | )); |
| 227 | 227 | } |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - /** |
|
| 231 | - * Show the form for editing the specified resource. |
|
| 232 | - * |
|
| 233 | - * @param int $id |
|
| 234 | - * @return Response |
|
| 235 | - */ |
|
| 236 | - public function edit($id) |
|
| 237 | - {
|
|
| 230 | + /** |
|
| 231 | + * Show the form for editing the specified resource. |
|
| 232 | + * |
|
| 233 | + * @param int $id |
|
| 234 | + * @return Response |
|
| 235 | + */ |
|
| 236 | + public function edit($id) |
|
| 237 | + {
|
|
| 238 | 238 | try {
|
| 239 | 239 | $error = false; |
| 240 | 240 | $statusCode = 200; |
@@ -260,27 +260,27 @@ discard block |
||
| 260 | 260 | $category = 'Not Found'; |
| 261 | 261 | } finally {
|
| 262 | 262 | return Response::json(array( |
| 263 | - 'error' => $error, |
|
| 264 | - 'status' => $statusCode, |
|
| 265 | - 'title' => $title, |
|
| 266 | - 'type' => $type, |
|
| 267 | - 'message' => $message, |
|
| 268 | - 'result' => $result, |
|
| 269 | - 'city' => $city, |
|
| 270 | - 'tanggal' => $format, |
|
| 271 | - 'category' => $category, |
|
| 263 | + 'error' => $error, |
|
| 264 | + 'status' => $statusCode, |
|
| 265 | + 'title' => $title, |
|
| 266 | + 'type' => $type, |
|
| 267 | + 'message' => $message, |
|
| 268 | + 'result' => $result, |
|
| 269 | + 'city' => $city, |
|
| 270 | + 'tanggal' => $format, |
|
| 271 | + 'category' => $category, |
|
| 272 | 272 | )); |
| 273 | 273 | } |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * Update the specified resource in storage. |
|
| 278 | - * |
|
| 279 | - * @param int $id |
|
| 280 | - * @return Response |
|
| 281 | - */ |
|
| 282 | - public function update(Request $request, $version='', $id) |
|
| 283 | - {
|
|
| 276 | + /** |
|
| 277 | + * Update the specified resource in storage. |
|
| 278 | + * |
|
| 279 | + * @param int $id |
|
| 280 | + * @return Response |
|
| 281 | + */ |
|
| 282 | + public function update(Request $request, $version='', $id) |
|
| 283 | + {
|
|
| 284 | 284 | $result = EpormasCounter::whereNull('deleted_at')
|
| 285 | 285 | ->with('getCity')
|
| 286 | 286 | ->with('getCategory')
|
@@ -295,28 +295,28 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | $validator = Validator::make($request->all(), $rules); |
| 297 | 297 | if ($validator->fails()) {
|
| 298 | - return response()->json([ |
|
| 299 | - 'title' => 'Error', |
|
| 300 | - 'type' => 'error', |
|
| 301 | - 'message' => $validator->errors()->all() |
|
| 302 | - ]); |
|
| 298 | + return response()->json([ |
|
| 299 | + 'title' => 'Error', |
|
| 300 | + 'type' => 'error', |
|
| 301 | + 'message' => $validator->errors()->all() |
|
| 302 | + ]); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
| 306 | 306 | if($result->city_id != $request->city_id || $result->category_id != $request->category_id){
|
| 307 | 307 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 308 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 309 | - ->where('category_id',$request->category_id)
|
|
| 310 | - ->where('city_id',$request->city_id)
|
|
| 311 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 312 | - ->orderBy('bulan')
|
|
| 313 | - ->count(); |
|
| 308 | + ->where('tanggal','like','%'.$format.'%')
|
|
| 309 | + ->where('category_id',$request->category_id)
|
|
| 310 | + ->where('city_id',$request->city_id)
|
|
| 311 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 312 | + ->orderBy('bulan')
|
|
| 313 | + ->count(); |
|
| 314 | 314 | if($resultcek > 0){
|
| 315 | - return response()->json([ |
|
| 316 | - 'title' => 'Error', |
|
| 317 | - 'type' => 'error', |
|
| 318 | - 'message' => 'Data has already been taken.' |
|
| 319 | - ]); |
|
| 315 | + return response()->json([ |
|
| 316 | + 'title' => 'Error', |
|
| 317 | + 'type' => 'error', |
|
| 318 | + 'message' => 'Data has already been taken.' |
|
| 319 | + ]); |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
@@ -324,34 +324,34 @@ discard block |
||
| 324 | 324 | $dates = date('Y-m-d', strtotime($result->tanggal));
|
| 325 | 325 | if($dates != $format){
|
| 326 | 326 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 327 | - ->where('category_id',$request->category_id)
|
|
| 328 | - ->where('city_id',$request->city_id)
|
|
| 329 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 330 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 331 | - ->orderBy('bulan')
|
|
| 332 | - ->count(); |
|
| 327 | + ->where('category_id',$request->category_id)
|
|
| 328 | + ->where('city_id',$request->city_id)
|
|
| 329 | + ->where('tanggal','like','%'.$format.'%')
|
|
| 330 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 331 | + ->orderBy('bulan')
|
|
| 332 | + ->count(); |
|
| 333 | 333 | if($resultcek > 0){
|
| 334 | - return response()->json([ |
|
| 335 | - 'title' => 'Error', |
|
| 336 | - 'type' => 'error', |
|
| 337 | - 'message' => 'Data has already been taken.' |
|
| 338 | - ]); |
|
| 334 | + return response()->json([ |
|
| 335 | + 'title' => 'Error', |
|
| 336 | + 'type' => 'error', |
|
| 337 | + 'message' => 'Data has already been taken.' |
|
| 338 | + ]); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | $data = EpormasCounter::whereNull('deleted_at')
|
| 342 | - ->where('tahun', $date[0])
|
|
| 343 | - ->where('bulan', $date[1])
|
|
| 344 | - ->where('category_id',$request->category_id)
|
|
| 345 | - ->where('city_id',$request->city_id)
|
|
| 346 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 347 | - ->orderBy('bulan')
|
|
| 348 | - ->count(); |
|
| 342 | + ->where('tahun', $date[0])
|
|
| 343 | + ->where('bulan', $date[1])
|
|
| 344 | + ->where('category_id',$request->category_id)
|
|
| 345 | + ->where('city_id',$request->city_id)
|
|
| 346 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 347 | + ->orderBy('bulan')
|
|
| 348 | + ->count(); |
|
| 349 | 349 | if($data > 0){
|
| 350 | - return response()->json([ |
|
| 351 | - 'title' => 'Error', |
|
| 352 | - 'type' => 'error', |
|
| 353 | - 'message' => 'Data has already been taken.' |
|
| 354 | - ]); |
|
| 350 | + return response()->json([ |
|
| 351 | + 'title' => 'Error', |
|
| 352 | + 'type' => 'error', |
|
| 353 | + 'message' => 'Data has already been taken.' |
|
| 354 | + ]); |
|
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | |
@@ -361,13 +361,13 @@ discard block |
||
| 361 | 361 | $from = $result->via; |
| 362 | 362 | $user_id = $result->user_id; |
| 363 | 363 | if(in_array('api',$explode)){
|
| 364 | - $from = 'api'; |
|
| 365 | - $user_id = $request->user_id; |
|
| 364 | + $from = 'api'; |
|
| 365 | + $user_id = $request->user_id; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | $via = $from; |
| 369 | 369 | if($version != '' && $version != 'update'){
|
| 370 | - $via .= '-'.$version; |
|
| 370 | + $via .= '-'.$version; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | try {
|
@@ -395,47 +395,47 @@ discard block |
||
| 395 | 395 | $result = 'Not Found'; |
| 396 | 396 | } finally {
|
| 397 | 397 | return Response::json(array( |
| 398 | - 'error' => $error, |
|
| 399 | - 'status' => $statusCode, |
|
| 400 | - 'title' => $title, |
|
| 401 | - 'type' => $type, |
|
| 402 | - 'message' => $message, |
|
| 403 | - 'result' => $result |
|
| 398 | + 'error' => $error, |
|
| 399 | + 'status' => $statusCode, |
|
| 400 | + 'title' => $title, |
|
| 401 | + 'type' => $type, |
|
| 402 | + 'message' => $message, |
|
| 403 | + 'result' => $result |
|
| 404 | 404 | )); |
| 405 | 405 | } |
| 406 | - } |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * Remove the specified resource from storage. |
|
| 410 | - * |
|
| 411 | - * @param int $id |
|
| 412 | - * @return Response |
|
| 413 | - */ |
|
| 414 | - public function destroy($id) |
|
| 415 | - {
|
|
| 416 | - try {
|
|
| 417 | - EpormasCounter::find($id)->delete(); |
|
| 418 | - $error = false; |
|
| 419 | - $statusCode = 200; |
|
| 420 | - $title = 'Success'; |
|
| 421 | - $type = 'success'; |
|
| 422 | - $message = 'Data deleted successfully'; |
|
| 423 | - } catch (Exception $e) {
|
|
| 424 | - $error = true; |
|
| 425 | - $statusCode = 404; |
|
| 426 | - $title = 'Error'; |
|
| 427 | - $type = 'error'; |
|
| 428 | - $message = 'Error'; |
|
| 429 | - } finally {
|
|
| 430 | - return Response::json(array( |
|
| 408 | + /** |
|
| 409 | + * Remove the specified resource from storage. |
|
| 410 | + * |
|
| 411 | + * @param int $id |
|
| 412 | + * @return Response |
|
| 413 | + */ |
|
| 414 | + public function destroy($id) |
|
| 415 | + {
|
|
| 416 | + try {
|
|
| 417 | + EpormasCounter::find($id)->delete(); |
|
| 418 | + $error = false; |
|
| 419 | + $statusCode = 200; |
|
| 420 | + $title = 'Success'; |
|
| 421 | + $type = 'success'; |
|
| 422 | + $message = 'Data deleted successfully'; |
|
| 423 | + } catch (Exception $e) {
|
|
| 424 | + $error = true; |
|
| 425 | + $statusCode = 404; |
|
| 426 | + $title = 'Error'; |
|
| 427 | + $type = 'error'; |
|
| 428 | + $message = 'Error'; |
|
| 429 | + } finally {
|
|
| 430 | + return Response::json(array( |
|
| 431 | 431 | 'error' => $error, |
| 432 | 432 | 'status' => $statusCode, |
| 433 | 433 | 'title' => $title, |
| 434 | 434 | 'type' => $type, |
| 435 | 435 | 'message' => $message |
| 436 | - )); |
|
| 437 | - } |
|
| 438 | - } |
|
| 436 | + )); |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | 440 | } |
| 441 | 441 | |
@@ -91,18 +91,18 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return Response |
| 93 | 93 | */ |
| 94 | - public function store(Request $request, $version='') |
|
| 94 | + public function store(Request $request, $version = '') |
|
| 95 | 95 | {
|
| 96 | 96 | $path = \Request::path(); |
| 97 | 97 | $explode = explode('/', $path);
|
| 98 | 98 | |
| 99 | 99 | $from = 'form'; |
| 100 | - if(in_array('api',$explode)){
|
|
| 100 | + if (in_array('api', $explode)) {
|
|
| 101 | 101 | $from = 'api'; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | $via = $from; |
| 105 | - if($version != '' && $version != 'store'){
|
|
| 105 | + if ($version != '' && $version != 'store') {
|
|
| 106 | 106 | $via .= '-'.$version; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -122,15 +122,15 @@ discard block |
||
| 122 | 122 | ]); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
|
| 125 | + $format = date('Y-m-d', strtotime(str_replace(' ', '-', $request->tanggal)));
|
|
| 126 | 126 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 127 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 128 | - ->where('category_id',$request->category_id)
|
|
| 129 | - ->where('city_id',$request->city_id)
|
|
| 130 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 127 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 128 | + ->where('category_id', $request->category_id)
|
|
| 129 | + ->where('city_id', $request->city_id)
|
|
| 130 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 131 | 131 | ->orderBy('bulan')
|
| 132 | 132 | ->count(); |
| 133 | - if($resultcek > 0){
|
|
| 133 | + if ($resultcek > 0) {
|
|
| 134 | 134 | return response()->json([ |
| 135 | 135 | 'title' => 'Error', |
| 136 | 136 | 'type' => 'error', |
@@ -138,16 +138,16 @@ discard block |
||
| 138 | 138 | ]); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - $date = explode("-",$format);
|
|
| 141 | + $date = explode("-", $format);
|
|
| 142 | 142 | $data = EpormasCounter::whereNull('deleted_at')
|
| 143 | 143 | ->where('tahun', $date[0])
|
| 144 | 144 | ->where('bulan', $date[1])
|
| 145 | - ->where('category_id',$request->category_id)
|
|
| 146 | - ->where('city_id',$request->city_id)
|
|
| 147 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 145 | + ->where('category_id', $request->category_id)
|
|
| 146 | + ->where('city_id', $request->city_id)
|
|
| 147 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 148 | 148 | ->orderBy('bulan')
|
| 149 | 149 | ->count(); |
| 150 | - if($data > 0){
|
|
| 150 | + if ($data > 0) {
|
|
| 151 | 151 | return response()->json([ |
| 152 | 152 | 'title' => 'Error', |
| 153 | 153 | 'type' => 'error', |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param int $id |
| 197 | 197 | * @return Response |
| 198 | 198 | */ |
| 199 | - public function show($version='', $id) |
|
| 199 | + public function show($version = '', $id) |
|
| 200 | 200 | {
|
| 201 | 201 | try {
|
| 202 | 202 | $error = false; |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * @param int $id |
| 280 | 280 | * @return Response |
| 281 | 281 | */ |
| 282 | - public function update(Request $request, $version='', $id) |
|
| 282 | + public function update(Request $request, $version = '', $id) |
|
| 283 | 283 | {
|
| 284 | 284 | $result = EpormasCounter::whereNull('deleted_at')
|
| 285 | 285 | ->with('getCity')
|
@@ -302,16 +302,16 @@ discard block |
||
| 302 | 302 | ]); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
|
| 306 | - if($result->city_id != $request->city_id || $result->category_id != $request->category_id){
|
|
| 305 | + $format = date('Y-m-d', strtotime(str_replace(' ', '-', $request->tanggal)));
|
|
| 306 | + if ($result->city_id != $request->city_id || $result->category_id != $request->category_id) {
|
|
| 307 | 307 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 308 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 309 | - ->where('category_id',$request->category_id)
|
|
| 310 | - ->where('city_id',$request->city_id)
|
|
| 311 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 308 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 309 | + ->where('category_id', $request->category_id)
|
|
| 310 | + ->where('city_id', $request->city_id)
|
|
| 311 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 312 | 312 | ->orderBy('bulan')
|
| 313 | 313 | ->count(); |
| 314 | - if($resultcek > 0){
|
|
| 314 | + if ($resultcek > 0) {
|
|
| 315 | 315 | return response()->json([ |
| 316 | 316 | 'title' => 'Error', |
| 317 | 317 | 'type' => 'error', |
@@ -320,17 +320,17 @@ discard block |
||
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - $date = explode("-",$format);
|
|
| 323 | + $date = explode("-", $format);
|
|
| 324 | 324 | $dates = date('Y-m-d', strtotime($result->tanggal));
|
| 325 | - if($dates != $format){
|
|
| 325 | + if ($dates != $format) {
|
|
| 326 | 326 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 327 | - ->where('category_id',$request->category_id)
|
|
| 328 | - ->where('city_id',$request->city_id)
|
|
| 329 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 330 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 327 | + ->where('category_id', $request->category_id)
|
|
| 328 | + ->where('city_id', $request->city_id)
|
|
| 329 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 330 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 331 | 331 | ->orderBy('bulan')
|
| 332 | 332 | ->count(); |
| 333 | - if($resultcek > 0){
|
|
| 333 | + if ($resultcek > 0) {
|
|
| 334 | 334 | return response()->json([ |
| 335 | 335 | 'title' => 'Error', |
| 336 | 336 | 'type' => 'error', |
@@ -341,12 +341,12 @@ discard block |
||
| 341 | 341 | $data = EpormasCounter::whereNull('deleted_at')
|
| 342 | 342 | ->where('tahun', $date[0])
|
| 343 | 343 | ->where('bulan', $date[1])
|
| 344 | - ->where('category_id',$request->category_id)
|
|
| 345 | - ->where('city_id',$request->city_id)
|
|
| 346 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 344 | + ->where('category_id', $request->category_id)
|
|
| 345 | + ->where('city_id', $request->city_id)
|
|
| 346 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 347 | 347 | ->orderBy('bulan')
|
| 348 | 348 | ->count(); |
| 349 | - if($data > 0){
|
|
| 349 | + if ($data > 0) {
|
|
| 350 | 350 | return response()->json([ |
| 351 | 351 | 'title' => 'Error', |
| 352 | 352 | 'type' => 'error', |
@@ -360,13 +360,13 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | $from = $result->via; |
| 362 | 362 | $user_id = $result->user_id; |
| 363 | - if(in_array('api',$explode)){
|
|
| 363 | + if (in_array('api', $explode)) {
|
|
| 364 | 364 | $from = 'api'; |
| 365 | 365 | $user_id = $request->user_id; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | $via = $from; |
| 369 | - if($version != '' && $version != 'update'){
|
|
| 369 | + if ($version != '' && $version != 'update') {
|
|
| 370 | 370 | $via .= '-'.$version; |
| 371 | 371 | } |
| 372 | 372 | |
@@ -12,91 +12,91 @@ 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 | - } catch (Exception $e) {
|
|
| 30 | - $error = true; |
|
| 31 | - $statusCode = 404; |
|
| 32 | - $title = 'Error'; |
|
| 33 | - $type = 'error'; |
|
| 34 | - $message = 'Error'; |
|
| 35 | - $result = 'Not Found'; |
|
| 36 | - } finally {
|
|
| 37 | - 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 | + } catch (Exception $e) {
|
|
| 30 | + $error = true; |
|
| 31 | + $statusCode = 404; |
|
| 32 | + $title = 'Error'; |
|
| 33 | + $type = 'error'; |
|
| 34 | + $message = 'Error'; |
|
| 35 | + $result = 'Not Found'; |
|
| 36 | + } finally {
|
|
| 37 | + return Response::json(array( |
|
| 38 | 38 | 'error' => $error, |
| 39 | 39 | 'status' => $statusCode, |
| 40 | 40 | 'title' => $title, |
| 41 | 41 | 'type' => $type, |
| 42 | 42 | 'message' => $message, |
| 43 | 43 | 'result' => $result |
| 44 | - )); |
|
| 45 | - } |
|
| 46 | - } |
|
| 44 | + )); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Show the form for creating a new resource. |
|
| 50 | - * |
|
| 51 | - * @return Response |
|
| 52 | - */ |
|
| 53 | - public function create() |
|
| 54 | - {
|
|
| 48 | + /** |
|
| 49 | + * Show the form for creating a new resource. |
|
| 50 | + * |
|
| 51 | + * @return Response |
|
| 52 | + */ |
|
| 53 | + public function create() |
|
| 54 | + {
|
|
| 55 | 55 | |
| 56 | - } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Store a newly created resource in storage. |
|
| 60 | - * |
|
| 61 | - * @return Response |
|
| 62 | - */ |
|
| 63 | - public function store(Request $request, $version='') |
|
| 64 | - {
|
|
| 58 | + /** |
|
| 59 | + * Store a newly created resource in storage. |
|
| 60 | + * |
|
| 61 | + * @return Response |
|
| 62 | + */ |
|
| 63 | + public function store(Request $request, $version='') |
|
| 64 | + {
|
|
| 65 | 65 | $path = \Request::path(); |
| 66 | 66 | $explode = explode('/', $path);
|
| 67 | 67 | |
| 68 | 68 | $from = 'form'; |
| 69 | 69 | if(in_array('api',$explode)){
|
| 70 | - $from = 'api'; |
|
| 70 | + $from = 'api'; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $via = $from; |
| 74 | 74 | if($version != '' && $version != 'store'){
|
| 75 | - $via .= '-'.$version; |
|
| 75 | + $via .= '-'.$version; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $rules = [ |
|
| 78 | + $rules = [ |
|
| 79 | 79 | 'name' => 'required' |
| 80 | 80 | ]; |
| 81 | 81 | |
| 82 | 82 | $validator = Validator::make($request->all(), $rules); |
| 83 | 83 | if ($validator->fails()) {
|
| 84 | - return response()->json([ |
|
| 85 | - 'title' => 'Error', |
|
| 86 | - 'type' => 'error', |
|
| 87 | - 'message' => $validator->errors()->all() |
|
| 88 | - ]); |
|
| 84 | + return response()->json([ |
|
| 85 | + 'title' => 'Error', |
|
| 86 | + 'type' => 'error', |
|
| 87 | + 'message' => $validator->errors()->all() |
|
| 88 | + ]); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $data = EpormasCity::whereNull('deleted_at')
|
| 92 | 92 | ->where('name', $request->name)
|
| 93 | 93 | ->count(); |
| 94 | 94 | if($data > 0){
|
| 95 | - return response()->json([ |
|
| 96 | - 'title' => 'Error', |
|
| 97 | - 'type' => 'error', |
|
| 98 | - 'message' => 'Data has already been taken.' |
|
| 99 | - ]); |
|
| 95 | + return response()->json([ |
|
| 96 | + 'title' => 'Error', |
|
| 97 | + 'type' => 'error', |
|
| 98 | + 'message' => 'Data has already been taken.' |
|
| 99 | + ]); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | try {
|
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | $result = 'Not Found'; |
| 118 | 118 | } finally {
|
| 119 | 119 | return Response::json(array( |
| 120 | - 'error' => $error, |
|
| 121 | - 'status' => $statusCode, |
|
| 122 | - 'title' => $title, |
|
| 123 | - 'type' => $type, |
|
| 124 | - 'message' => $message, |
|
| 125 | - 'result' => $result |
|
| 120 | + 'error' => $error, |
|
| 121 | + 'status' => $statusCode, |
|
| 122 | + 'title' => $title, |
|
| 123 | + 'type' => $type, |
|
| 124 | + 'message' => $message, |
|
| 125 | + 'result' => $result |
|
| 126 | 126 | )); |
| 127 | 127 | } |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Display the specified resource. |
|
| 132 | - * |
|
| 133 | - * @param int $id |
|
| 134 | - * @return Response |
|
| 135 | - */ |
|
| 136 | - public function show($version='', $id) |
|
| 137 | - {
|
|
| 130 | + /** |
|
| 131 | + * Display the specified resource. |
|
| 132 | + * |
|
| 133 | + * @param int $id |
|
| 134 | + * @return Response |
|
| 135 | + */ |
|
| 136 | + public function show($version='', $id) |
|
| 137 | + {
|
|
| 138 | 138 | try {
|
| 139 | 139 | $error = false; |
| 140 | 140 | $statusCode = 200; |
@@ -151,24 +151,24 @@ discard block |
||
| 151 | 151 | $result = 'Not Found'; |
| 152 | 152 | } finally {
|
| 153 | 153 | return Response::json(array( |
| 154 | - 'error' => $error, |
|
| 155 | - 'status' => $statusCode, |
|
| 156 | - 'title' => $title, |
|
| 157 | - 'type' => $type, |
|
| 158 | - 'message' => $message, |
|
| 159 | - 'result' => $result |
|
| 154 | + 'error' => $error, |
|
| 155 | + 'status' => $statusCode, |
|
| 156 | + 'title' => $title, |
|
| 157 | + 'type' => $type, |
|
| 158 | + 'message' => $message, |
|
| 159 | + 'result' => $result |
|
| 160 | 160 | )); |
| 161 | 161 | } |
| 162 | - } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * Show the form for editing the specified resource. |
|
| 166 | - * |
|
| 167 | - * @param int $id |
|
| 168 | - * @return Response |
|
| 169 | - */ |
|
| 170 | - public function edit($id) |
|
| 171 | - {
|
|
| 164 | + /** |
|
| 165 | + * Show the form for editing the specified resource. |
|
| 166 | + * |
|
| 167 | + * @param int $id |
|
| 168 | + * @return Response |
|
| 169 | + */ |
|
| 170 | + public function edit($id) |
|
| 171 | + {
|
|
| 172 | 172 | try {
|
| 173 | 173 | $error = false; |
| 174 | 174 | $statusCode = 200; |
@@ -185,24 +185,24 @@ discard block |
||
| 185 | 185 | $result = 'Not Found'; |
| 186 | 186 | } finally {
|
| 187 | 187 | return Response::json(array( |
| 188 | - 'error' => $error, |
|
| 189 | - 'status' => $statusCode, |
|
| 190 | - 'title' => $title, |
|
| 191 | - 'type' => $type, |
|
| 192 | - 'message' => $message, |
|
| 193 | - 'result' => $result |
|
| 188 | + 'error' => $error, |
|
| 189 | + 'status' => $statusCode, |
|
| 190 | + 'title' => $title, |
|
| 191 | + 'type' => $type, |
|
| 192 | + 'message' => $message, |
|
| 193 | + 'result' => $result |
|
| 194 | 194 | )); |
| 195 | 195 | } |
| 196 | - } |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * Update the specified resource in storage. |
|
| 200 | - * |
|
| 201 | - * @param int $id |
|
| 202 | - * @return Response |
|
| 203 | - */ |
|
| 204 | - public function update(Request $request, $version='', $id) |
|
| 205 | - {
|
|
| 198 | + /** |
|
| 199 | + * Update the specified resource in storage. |
|
| 200 | + * |
|
| 201 | + * @param int $id |
|
| 202 | + * @return Response |
|
| 203 | + */ |
|
| 204 | + public function update(Request $request, $version='', $id) |
|
| 205 | + {
|
|
| 206 | 206 | $result = EpormasCity::find($id); |
| 207 | 207 | |
| 208 | 208 | $rules = [ |
@@ -211,24 +211,24 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | $validator = Validator::make($request->all(), $rules); |
| 213 | 213 | if ($validator->fails()) {
|
| 214 | - return response()->json([ |
|
| 215 | - 'title' => 'Error', |
|
| 216 | - 'type' => 'error', |
|
| 217 | - 'message' => $validator->errors()->all() |
|
| 218 | - ]); |
|
| 214 | + return response()->json([ |
|
| 215 | + 'title' => 'Error', |
|
| 216 | + 'type' => 'error', |
|
| 217 | + 'message' => $validator->errors()->all() |
|
| 218 | + ]); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | if($request->name != $result->name){
|
| 222 | - $data = EpormasCity::whereNull('deleted_at')
|
|
| 223 | - ->where('name', $request->name)
|
|
| 224 | - ->count(); |
|
| 225 | - if($data > 0){
|
|
| 222 | + $data = EpormasCity::whereNull('deleted_at')
|
|
| 223 | + ->where('name', $request->name)
|
|
| 224 | + ->count(); |
|
| 225 | + if($data > 0){
|
|
| 226 | 226 | return response()->json([ |
| 227 | 227 | 'title' => 'Error', |
| 228 | 228 | 'type' => 'error', |
| 229 | 229 | 'message' => 'Data has already been taken.' |
| 230 | 230 | ]); |
| 231 | - } |
|
| 231 | + } |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | $path = \Request::path(); |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $from = 'form'; |
| 238 | 238 | if(in_array('api',$explode)){
|
| 239 | - $from = 'api'; |
|
| 239 | + $from = 'api'; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $via = $from; |
| 243 | 243 | if($version != '' && $version != 'update'){
|
| 244 | - $via .= '-'.$version; |
|
| 244 | + $via .= '-'.$version; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | try {
|
@@ -262,47 +262,47 @@ discard block |
||
| 262 | 262 | $result = 'Not Found'; |
| 263 | 263 | } finally {
|
| 264 | 264 | return Response::json(array( |
| 265 | - 'error' => $error, |
|
| 266 | - 'status' => $statusCode, |
|
| 267 | - 'title' => $title, |
|
| 268 | - 'type' => $type, |
|
| 269 | - 'message' => $message, |
|
| 270 | - 'result' => $result |
|
| 265 | + 'error' => $error, |
|
| 266 | + 'status' => $statusCode, |
|
| 267 | + 'title' => $title, |
|
| 268 | + 'type' => $type, |
|
| 269 | + 'message' => $message, |
|
| 270 | + 'result' => $result |
|
| 271 | 271 | )); |
| 272 | 272 | } |
| 273 | - } |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - /** |
|
| 276 | - * Remove the specified resource from storage. |
|
| 277 | - * |
|
| 278 | - * @param int $id |
|
| 279 | - * @return Response |
|
| 280 | - */ |
|
| 281 | - public function destroy($id) |
|
| 282 | - {
|
|
| 283 | - try {
|
|
| 284 | - EpormasCity::find($id)->delete(); |
|
| 285 | - $error = false; |
|
| 286 | - $statusCode = 200; |
|
| 287 | - $title = 'Success'; |
|
| 288 | - $type = 'success'; |
|
| 289 | - $message = 'Data deleted successfully'; |
|
| 290 | - } catch (Exception $e) {
|
|
| 291 | - $error = true; |
|
| 292 | - $statusCode = 404; |
|
| 293 | - $title = 'Error'; |
|
| 294 | - $type = 'error'; |
|
| 295 | - $message = 'Error'; |
|
| 296 | - } finally {
|
|
| 297 | - return Response::json(array( |
|
| 275 | + /** |
|
| 276 | + * Remove the specified resource from storage. |
|
| 277 | + * |
|
| 278 | + * @param int $id |
|
| 279 | + * @return Response |
|
| 280 | + */ |
|
| 281 | + public function destroy($id) |
|
| 282 | + {
|
|
| 283 | + try {
|
|
| 284 | + EpormasCity::find($id)->delete(); |
|
| 285 | + $error = false; |
|
| 286 | + $statusCode = 200; |
|
| 287 | + $title = 'Success'; |
|
| 288 | + $type = 'success'; |
|
| 289 | + $message = 'Data deleted successfully'; |
|
| 290 | + } catch (Exception $e) {
|
|
| 291 | + $error = true; |
|
| 292 | + $statusCode = 404; |
|
| 293 | + $title = 'Error'; |
|
| 294 | + $type = 'error'; |
|
| 295 | + $message = 'Error'; |
|
| 296 | + } finally {
|
|
| 297 | + return Response::json(array( |
|
| 298 | 298 | 'error' => $error, |
| 299 | 299 | 'status' => $statusCode, |
| 300 | 300 | 'title' => $title, |
| 301 | 301 | 'type' => $type, |
| 302 | 302 | 'message' => $message |
| 303 | - )); |
|
| 304 | - } |
|
| 305 | - } |
|
| 303 | + )); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | 307 | } |
| 308 | 308 | |
@@ -60,18 +60,18 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return Response |
| 62 | 62 | */ |
| 63 | - public function store(Request $request, $version='') |
|
| 63 | + public function store(Request $request, $version = '') |
|
| 64 | 64 | {
|
| 65 | 65 | $path = \Request::path(); |
| 66 | 66 | $explode = explode('/', $path);
|
| 67 | 67 | |
| 68 | 68 | $from = 'form'; |
| 69 | - if(in_array('api',$explode)){
|
|
| 69 | + if (in_array('api', $explode)) {
|
|
| 70 | 70 | $from = 'api'; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $via = $from; |
| 74 | - if($version != '' && $version != 'store'){
|
|
| 74 | + if ($version != '' && $version != 'store') {
|
|
| 75 | 75 | $via .= '-'.$version; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $data = EpormasCity::whereNull('deleted_at')
|
| 92 | 92 | ->where('name', $request->name)
|
| 93 | 93 | ->count(); |
| 94 | - if($data > 0){
|
|
| 94 | + if ($data > 0) {
|
|
| 95 | 95 | return response()->json([ |
| 96 | 96 | 'title' => 'Error', |
| 97 | 97 | 'type' => 'error', |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param int $id |
| 134 | 134 | * @return Response |
| 135 | 135 | */ |
| 136 | - public function show($version='', $id) |
|
| 136 | + public function show($version = '', $id) |
|
| 137 | 137 | {
|
| 138 | 138 | try {
|
| 139 | 139 | $error = false; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @param int $id |
| 202 | 202 | * @return Response |
| 203 | 203 | */ |
| 204 | - public function update(Request $request, $version='', $id) |
|
| 204 | + public function update(Request $request, $version = '', $id) |
|
| 205 | 205 | {
|
| 206 | 206 | $result = EpormasCity::find($id); |
| 207 | 207 | |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | ]); |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if($request->name != $result->name){
|
|
| 221 | + if ($request->name != $result->name) {
|
|
| 222 | 222 | $data = EpormasCity::whereNull('deleted_at')
|
| 223 | 223 | ->where('name', $request->name)
|
| 224 | 224 | ->count(); |
| 225 | - if($data > 0){
|
|
| 225 | + if ($data > 0) {
|
|
| 226 | 226 | return response()->json([ |
| 227 | 227 | 'title' => 'Error', |
| 228 | 228 | 'type' => 'error', |
@@ -235,12 +235,12 @@ discard block |
||
| 235 | 235 | $explode = explode('/', $path);
|
| 236 | 236 | |
| 237 | 237 | $from = 'form'; |
| 238 | - if(in_array('api',$explode)){
|
|
| 238 | + if (in_array('api', $explode)) {
|
|
| 239 | 239 | $from = 'api'; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $via = $from; |
| 243 | - if($version != '' && $version != 'update'){
|
|
| 243 | + if ($version != '' && $version != 'update') {
|
|
| 244 | 244 | $via .= '-'.$version; |
| 245 | 245 | } |
| 246 | 246 | |
@@ -15,32 +15,32 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | public function epormas() |
| 17 | 17 | { |
| 18 | - //Pegawai Epormas |
|
| 19 | - $grafikepormascounter = DB::table('epormas_counter') |
|
| 18 | + //Pegawai Epormas |
|
| 19 | + $grafikepormascounter = DB::table('epormas_counter') |
|
| 20 | 20 | ->select('tahun','bulan','city_id', DB::raw('SUM(count) as count')) |
| 21 | 21 | ->whereNull('deleted_at')->groupBy('tahun','bulan','city_id')->orderBy('bulan')->get(); |
| 22 | - $grafiktahunepormascounter = DB::table('epormas_counter') |
|
| 22 | + $grafiktahunepormascounter = DB::table('epormas_counter') |
|
| 23 | 23 | ->select('tahun', DB::raw('SUM(count) as count')) |
| 24 | 24 | ->whereNull('deleted_at')->groupBy('tahun')->orderBy('tahun')->get(); |
| 25 | 25 | |
| 26 | - $namaBulan = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
|
| 27 | - $namaBulans = array('Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'); |
|
| 28 | - $city = EpormasCity::all(); |
|
| 29 | - $category = EpormasCategory::all(); |
|
| 30 | - $countcity = count($city); |
|
| 31 | - $countcategory = count($category); |
|
| 26 | + $namaBulan = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
|
| 27 | + $namaBulans = array('Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'); |
|
| 28 | + $city = EpormasCity::all(); |
|
| 29 | + $category = EpormasCategory::all(); |
|
| 30 | + $countcity = count($city); |
|
| 31 | + $countcategory = count($category); |
|
| 32 | 32 | |
| 33 | - $countgrafikepormascounter = count($grafikepormascounter); |
|
| 34 | - $countgrafiktahunepormascounter = count($grafiktahunepormascounter); |
|
| 35 | - $datagrafikepormascounter = []; |
|
| 36 | - $datagrafiktahunepormascounter = []; |
|
| 37 | - $datagrafikcountepormascounter = []; |
|
| 38 | - $datagrafiktotalepormascounter = []; |
|
| 39 | - $grafikcountepormascounter = []; |
|
| 40 | - $grafikbulanepormascounter = []; |
|
| 41 | - $grafiktotalepormascounter = []; |
|
| 42 | - $grafikpieepormascounter = []; |
|
| 43 | - for($q=0; $q<$countgrafiktahunepormascounter; $q++){ |
|
| 33 | + $countgrafikepormascounter = count($grafikepormascounter); |
|
| 34 | + $countgrafiktahunepormascounter = count($grafiktahunepormascounter); |
|
| 35 | + $datagrafikepormascounter = []; |
|
| 36 | + $datagrafiktahunepormascounter = []; |
|
| 37 | + $datagrafikcountepormascounter = []; |
|
| 38 | + $datagrafiktotalepormascounter = []; |
|
| 39 | + $grafikcountepormascounter = []; |
|
| 40 | + $grafikbulanepormascounter = []; |
|
| 41 | + $grafiktotalepormascounter = []; |
|
| 42 | + $grafikpieepormascounter = []; |
|
| 43 | + for($q=0; $q<$countgrafiktahunepormascounter; $q++){ |
|
| 44 | 44 | $tahungrafikepormascounter = $grafiktahunepormascounter[$q]->tahun; |
| 45 | 45 | $gcountepormascounter = (int)$grafiktahunepormascounter[$q]->count; |
| 46 | 46 | $totaldataepormascounter = $gcountepormascounter; |
@@ -50,47 +50,47 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | for($kota=1; $kota<=$countcity; $kota++){ |
| 52 | 52 | for ($index=0; $index<12; $index++) { |
| 53 | - $grafikcountepormascounter[$q][$kota][$index] = 0; |
|
| 54 | - $grafikbulanepormascounter[$q][$kota][$index] = 0; |
|
| 55 | - $grafiktotalepormascounter[$q][$kota][$index] = 0; |
|
| 56 | - $grafikpieepormascounter[$q][$kota][$index] = ['value'=>0,'name'=>$namaBulan[$index]]; |
|
| 57 | - $totaldatagrafikepormascounter[$q][$index] = 0; |
|
| 53 | + $grafikcountepormascounter[$q][$kota][$index] = 0; |
|
| 54 | + $grafikbulanepormascounter[$q][$kota][$index] = 0; |
|
| 55 | + $grafiktotalepormascounter[$q][$kota][$index] = 0; |
|
| 56 | + $grafikpieepormascounter[$q][$kota][$index] = ['value'=>0,'name'=>$namaBulan[$index]]; |
|
| 57 | + $totaldatagrafikepormascounter[$q][$index] = 0; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | for($r=0; $r<$countgrafikepormascounter; $r++){ |
| 61 | - $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
|
| 62 | - $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
|
| 63 | - $city_id = $grafikepormascounter[$r]->city_id; |
|
| 64 | - if($bulansepormascounter < 10){ |
|
| 61 | + $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
|
| 62 | + $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
|
| 63 | + $city_id = $grafikepormascounter[$r]->city_id; |
|
| 64 | + if($bulansepormascounter < 10){ |
|
| 65 | 65 | $bulanepormascounter = substr($bulansepormascounter,1); |
| 66 | - }else { |
|
| 66 | + }else { |
|
| 67 | 67 | $bulanepormascounter = $bulansepormascounter; |
| 68 | - } |
|
| 69 | - if($tahungrafikepormascounter == $tahunsepormascounter){ |
|
| 70 | - $totaldatagrafikepormascounter[$q][$bulanepormascounter-1] += $grafikepormascounter[$r]->count; |
|
| 71 | - } |
|
| 68 | + } |
|
| 69 | + if($tahungrafikepormascounter == $tahunsepormascounter){ |
|
| 70 | + $totaldatagrafikepormascounter[$q][$bulanepormascounter-1] += $grafikepormascounter[$r]->count; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | for($r=0; $r<$countgrafikepormascounter; $r++){ |
| 74 | - $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
|
| 75 | - $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
|
| 76 | - $city_id = $grafikepormascounter[$r]->city_id; |
|
| 77 | - if($bulansepormascounter < 10){ |
|
| 74 | + $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
|
| 75 | + $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
|
| 76 | + $city_id = $grafikepormascounter[$r]->city_id; |
|
| 77 | + if($bulansepormascounter < 10){ |
|
| 78 | 78 | $bulanepormascounter = substr($bulansepormascounter,1); |
| 79 | - }else { |
|
| 79 | + }else { |
|
| 80 | 80 | $bulanepormascounter = $bulansepormascounter; |
| 81 | - } |
|
| 82 | - if($tahungrafikepormascounter == $tahunsepormascounter){ |
|
| 83 | - $grafikcountepormascounter[$q][$city_id][$bulanepormascounter-1] = (int)$grafikepormascounter[$r]->count; |
|
| 84 | - $grafikbulanepormascounter[$q][$city_id][$bulanepormascounter-1] = $grafikepormascounter[$r]->bulan; |
|
| 85 | - $totaldatagrafikepormascounters = $totaldatagrafikepormascounter[$q][$bulanepormascounter-1]; |
|
| 86 | - $grafiktotalepormascounter[$q][$city_id][$bulanepormascounter-1] = $totaldatagrafikepormascounters; |
|
| 87 | - $grafikpieepormascounter[$q][$city_id][$bulanepormascounter-1] = ['value'=>$totaldatagrafikepormascounters,'name'=>$namaBulan[$bulanepormascounter-1]]; |
|
| 88 | - } |
|
| 81 | + } |
|
| 82 | + if($tahungrafikepormascounter == $tahunsepormascounter){ |
|
| 83 | + $grafikcountepormascounter[$q][$city_id][$bulanepormascounter-1] = (int)$grafikepormascounter[$r]->count; |
|
| 84 | + $grafikbulanepormascounter[$q][$city_id][$bulanepormascounter-1] = $grafikepormascounter[$r]->bulan; |
|
| 85 | + $totaldatagrafikepormascounters = $totaldatagrafikepormascounter[$q][$bulanepormascounter-1]; |
|
| 86 | + $grafiktotalepormascounter[$q][$city_id][$bulanepormascounter-1] = $totaldatagrafikepormascounters; |
|
| 87 | + $grafikpieepormascounter[$q][$city_id][$bulanepormascounter-1] = ['value'=>$totaldatagrafikepormascounters,'name'=>$namaBulan[$bulanepormascounter-1]]; |
|
| 88 | + } |
|
| 89 | + } |
|
| 89 | 90 | } |
| 90 | - } |
|
| 91 | - $chartgrafikcountepormascounter = ['chartdata'=>$grafikcountepormascounter]; |
|
| 92 | - $datagrafikepormascounter = ['count'=>$grafikcountepormascounter, 'bulan'=>$grafikbulanepormascounter, 'namabulan'=>$namaBulan, 'namabulans'=>$namaBulans, 'kategori'=>$category, 'kota'=>$city, 'total'=>$grafiktotalepormascounter, 'datatahun'=>['tahun'=>$datagrafiktahunepormascounter, 'count'=>$datagrafikcountepormascounter, 'totaldata'=>$datagrafiktotalepormascounter], 'datapie'=>$grafikpieepormascounter, 'seriesdata'=>[$chartgrafikcountepormascounter]]; |
|
| 93 | - //end Pegawai Epormas |
|
| 91 | + $chartgrafikcountepormascounter = ['chartdata'=>$grafikcountepormascounter]; |
|
| 92 | + $datagrafikepormascounter = ['count'=>$grafikcountepormascounter, 'bulan'=>$grafikbulanepormascounter, 'namabulan'=>$namaBulan, 'namabulans'=>$namaBulans, 'kategori'=>$category, 'kota'=>$city, 'total'=>$grafiktotalepormascounter, 'datatahun'=>['tahun'=>$datagrafiktahunepormascounter, 'count'=>$datagrafikcountepormascounter, 'totaldata'=>$datagrafiktotalepormascounter], 'datapie'=>$grafikpieepormascounter, 'seriesdata'=>[$chartgrafikcountepormascounter]]; |
|
| 93 | + //end Pegawai Epormas |
|
| 94 | 94 | |
| 95 | 95 | return Response::json(array( |
| 96 | 96 | //Jumlah Penduduk |
@@ -12,91 +12,91 @@ 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 | - } catch (Exception $e) {
|
|
| 30 | - $error = true; |
|
| 31 | - $statusCode = 404; |
|
| 32 | - $title = 'Error'; |
|
| 33 | - $type = 'error'; |
|
| 34 | - $message = 'Error'; |
|
| 35 | - $result = 'Not Found'; |
|
| 36 | - } finally {
|
|
| 37 | - 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 | + } catch (Exception $e) {
|
|
| 30 | + $error = true; |
|
| 31 | + $statusCode = 404; |
|
| 32 | + $title = 'Error'; |
|
| 33 | + $type = 'error'; |
|
| 34 | + $message = 'Error'; |
|
| 35 | + $result = 'Not Found'; |
|
| 36 | + } finally {
|
|
| 37 | + return Response::json(array( |
|
| 38 | 38 | 'error' => $error, |
| 39 | 39 | 'status' => $statusCode, |
| 40 | 40 | 'title' => $title, |
| 41 | 41 | 'type' => $type, |
| 42 | 42 | 'message' => $message, |
| 43 | 43 | 'result' => $result |
| 44 | - )); |
|
| 45 | - } |
|
| 46 | - } |
|
| 44 | + )); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Show the form for creating a new resource. |
|
| 50 | - * |
|
| 51 | - * @return Response |
|
| 52 | - */ |
|
| 53 | - public function create() |
|
| 54 | - {
|
|
| 48 | + /** |
|
| 49 | + * Show the form for creating a new resource. |
|
| 50 | + * |
|
| 51 | + * @return Response |
|
| 52 | + */ |
|
| 53 | + public function create() |
|
| 54 | + {
|
|
| 55 | 55 | |
| 56 | - } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Store a newly created resource in storage. |
|
| 60 | - * |
|
| 61 | - * @return Response |
|
| 62 | - */ |
|
| 63 | - public function store(Request $request, $version='') |
|
| 64 | - {
|
|
| 58 | + /** |
|
| 59 | + * Store a newly created resource in storage. |
|
| 60 | + * |
|
| 61 | + * @return Response |
|
| 62 | + */ |
|
| 63 | + public function store(Request $request, $version='') |
|
| 64 | + {
|
|
| 65 | 65 | $path = \Request::path(); |
| 66 | 66 | $explode = explode('/', $path);
|
| 67 | 67 | |
| 68 | 68 | $from = 'form'; |
| 69 | 69 | if(in_array('api',$explode)){
|
| 70 | - $from = 'api'; |
|
| 70 | + $from = 'api'; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $via = $from; |
| 74 | 74 | if($version != '' && $version != 'store'){
|
| 75 | - $via .= '-'.$version; |
|
| 75 | + $via .= '-'.$version; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $rules = [ |
|
| 78 | + $rules = [ |
|
| 79 | 79 | 'name' => 'required' |
| 80 | 80 | ]; |
| 81 | 81 | |
| 82 | 82 | $validator = Validator::make($request->all(), $rules); |
| 83 | 83 | if ($validator->fails()) {
|
| 84 | - return response()->json([ |
|
| 85 | - 'title' => 'Error', |
|
| 86 | - 'type' => 'error', |
|
| 87 | - 'message' => $validator->errors()->all() |
|
| 88 | - ]); |
|
| 84 | + return response()->json([ |
|
| 85 | + 'title' => 'Error', |
|
| 86 | + 'type' => 'error', |
|
| 87 | + 'message' => $validator->errors()->all() |
|
| 88 | + ]); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $data = EpormasCategory::whereNull('deleted_at')
|
| 92 | 92 | ->where('name', $request->name)
|
| 93 | 93 | ->count(); |
| 94 | 94 | if($data > 0){
|
| 95 | - return response()->json([ |
|
| 96 | - 'title' => 'Error', |
|
| 97 | - 'type' => 'error', |
|
| 98 | - 'message' => 'Data has already been taken.' |
|
| 99 | - ]); |
|
| 95 | + return response()->json([ |
|
| 96 | + 'title' => 'Error', |
|
| 97 | + 'type' => 'error', |
|
| 98 | + 'message' => 'Data has already been taken.' |
|
| 99 | + ]); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | try {
|
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | $result = 'Not Found'; |
| 118 | 118 | } finally {
|
| 119 | 119 | return Response::json(array( |
| 120 | - 'error' => $error, |
|
| 121 | - 'status' => $statusCode, |
|
| 122 | - 'title' => $title, |
|
| 123 | - 'type' => $type, |
|
| 124 | - 'message' => $message, |
|
| 125 | - 'result' => $result |
|
| 120 | + 'error' => $error, |
|
| 121 | + 'status' => $statusCode, |
|
| 122 | + 'title' => $title, |
|
| 123 | + 'type' => $type, |
|
| 124 | + 'message' => $message, |
|
| 125 | + 'result' => $result |
|
| 126 | 126 | )); |
| 127 | 127 | } |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Display the specified resource. |
|
| 132 | - * |
|
| 133 | - * @param int $id |
|
| 134 | - * @return Response |
|
| 135 | - */ |
|
| 136 | - public function show($version='', $id) |
|
| 137 | - {
|
|
| 130 | + /** |
|
| 131 | + * Display the specified resource. |
|
| 132 | + * |
|
| 133 | + * @param int $id |
|
| 134 | + * @return Response |
|
| 135 | + */ |
|
| 136 | + public function show($version='', $id) |
|
| 137 | + {
|
|
| 138 | 138 | try {
|
| 139 | 139 | $error = false; |
| 140 | 140 | $statusCode = 200; |
@@ -151,24 +151,24 @@ discard block |
||
| 151 | 151 | $result = 'Not Found'; |
| 152 | 152 | } finally {
|
| 153 | 153 | return Response::json(array( |
| 154 | - 'error' => $error, |
|
| 155 | - 'status' => $statusCode, |
|
| 156 | - 'title' => $title, |
|
| 157 | - 'type' => $type, |
|
| 158 | - 'message' => $message, |
|
| 159 | - 'result' => $result |
|
| 154 | + 'error' => $error, |
|
| 155 | + 'status' => $statusCode, |
|
| 156 | + 'title' => $title, |
|
| 157 | + 'type' => $type, |
|
| 158 | + 'message' => $message, |
|
| 159 | + 'result' => $result |
|
| 160 | 160 | )); |
| 161 | 161 | } |
| 162 | - } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * Show the form for editing the specified resource. |
|
| 166 | - * |
|
| 167 | - * @param int $id |
|
| 168 | - * @return Response |
|
| 169 | - */ |
|
| 170 | - public function edit($id) |
|
| 171 | - {
|
|
| 164 | + /** |
|
| 165 | + * Show the form for editing the specified resource. |
|
| 166 | + * |
|
| 167 | + * @param int $id |
|
| 168 | + * @return Response |
|
| 169 | + */ |
|
| 170 | + public function edit($id) |
|
| 171 | + {
|
|
| 172 | 172 | try {
|
| 173 | 173 | $error = false; |
| 174 | 174 | $statusCode = 200; |
@@ -185,24 +185,24 @@ discard block |
||
| 185 | 185 | $result = 'Not Found'; |
| 186 | 186 | } finally {
|
| 187 | 187 | return Response::json(array( |
| 188 | - 'error' => $error, |
|
| 189 | - 'status' => $statusCode, |
|
| 190 | - 'title' => $title, |
|
| 191 | - 'type' => $type, |
|
| 192 | - 'message' => $message, |
|
| 193 | - 'result' => $result |
|
| 188 | + 'error' => $error, |
|
| 189 | + 'status' => $statusCode, |
|
| 190 | + 'title' => $title, |
|
| 191 | + 'type' => $type, |
|
| 192 | + 'message' => $message, |
|
| 193 | + 'result' => $result |
|
| 194 | 194 | )); |
| 195 | 195 | } |
| 196 | - } |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * Update the specified resource in storage. |
|
| 200 | - * |
|
| 201 | - * @param int $id |
|
| 202 | - * @return Response |
|
| 203 | - */ |
|
| 204 | - public function update(Request $request, $version='', $id) |
|
| 205 | - {
|
|
| 198 | + /** |
|
| 199 | + * Update the specified resource in storage. |
|
| 200 | + * |
|
| 201 | + * @param int $id |
|
| 202 | + * @return Response |
|
| 203 | + */ |
|
| 204 | + public function update(Request $request, $version='', $id) |
|
| 205 | + {
|
|
| 206 | 206 | $result = EpormasCategory::find($id); |
| 207 | 207 | |
| 208 | 208 | $rules = [ |
@@ -211,24 +211,24 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | $validator = Validator::make($request->all(), $rules); |
| 213 | 213 | if ($validator->fails()) {
|
| 214 | - return response()->json([ |
|
| 215 | - 'title' => 'Error', |
|
| 216 | - 'type' => 'error', |
|
| 217 | - 'message' => $validator->errors()->all() |
|
| 218 | - ]); |
|
| 214 | + return response()->json([ |
|
| 215 | + 'title' => 'Error', |
|
| 216 | + 'type' => 'error', |
|
| 217 | + 'message' => $validator->errors()->all() |
|
| 218 | + ]); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | if($request->name != $result->name){
|
| 222 | - $data = EpormasCategory::whereNull('deleted_at')
|
|
| 223 | - ->where('name', $request->name)
|
|
| 224 | - ->count(); |
|
| 225 | - if($data > 0){
|
|
| 222 | + $data = EpormasCategory::whereNull('deleted_at')
|
|
| 223 | + ->where('name', $request->name)
|
|
| 224 | + ->count(); |
|
| 225 | + if($data > 0){
|
|
| 226 | 226 | return response()->json([ |
| 227 | 227 | 'title' => 'Error', |
| 228 | 228 | 'type' => 'error', |
| 229 | 229 | 'message' => 'Data has already been taken.' |
| 230 | 230 | ]); |
| 231 | - } |
|
| 231 | + } |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | $path = \Request::path(); |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $from = 'form'; |
| 238 | 238 | if(in_array('api',$explode)){
|
| 239 | - $from = 'api'; |
|
| 239 | + $from = 'api'; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $via = $from; |
| 243 | 243 | if($version != '' && $version != 'update'){
|
| 244 | - $via .= '-'.$version; |
|
| 244 | + $via .= '-'.$version; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | try {
|
@@ -262,47 +262,47 @@ discard block |
||
| 262 | 262 | $result = 'Not Found'; |
| 263 | 263 | } finally {
|
| 264 | 264 | return Response::json(array( |
| 265 | - 'error' => $error, |
|
| 266 | - 'status' => $statusCode, |
|
| 267 | - 'title' => $title, |
|
| 268 | - 'type' => $type, |
|
| 269 | - 'message' => $message, |
|
| 270 | - 'result' => $result |
|
| 265 | + 'error' => $error, |
|
| 266 | + 'status' => $statusCode, |
|
| 267 | + 'title' => $title, |
|
| 268 | + 'type' => $type, |
|
| 269 | + 'message' => $message, |
|
| 270 | + 'result' => $result |
|
| 271 | 271 | )); |
| 272 | 272 | } |
| 273 | - } |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - /** |
|
| 276 | - * Remove the specified resource from storage. |
|
| 277 | - * |
|
| 278 | - * @param int $id |
|
| 279 | - * @return Response |
|
| 280 | - */ |
|
| 281 | - public function destroy($id) |
|
| 282 | - {
|
|
| 283 | - try {
|
|
| 284 | - EpormasCategory::find($id)->delete(); |
|
| 285 | - $error = false; |
|
| 286 | - $statusCode = 200; |
|
| 287 | - $title = 'Success'; |
|
| 288 | - $type = 'success'; |
|
| 289 | - $message = 'Data deleted successfully'; |
|
| 290 | - } catch (Exception $e) {
|
|
| 291 | - $error = true; |
|
| 292 | - $statusCode = 404; |
|
| 293 | - $title = 'Error'; |
|
| 294 | - $type = 'error'; |
|
| 295 | - $message = 'Error'; |
|
| 296 | - } finally {
|
|
| 297 | - return Response::json(array( |
|
| 275 | + /** |
|
| 276 | + * Remove the specified resource from storage. |
|
| 277 | + * |
|
| 278 | + * @param int $id |
|
| 279 | + * @return Response |
|
| 280 | + */ |
|
| 281 | + public function destroy($id) |
|
| 282 | + {
|
|
| 283 | + try {
|
|
| 284 | + EpormasCategory::find($id)->delete(); |
|
| 285 | + $error = false; |
|
| 286 | + $statusCode = 200; |
|
| 287 | + $title = 'Success'; |
|
| 288 | + $type = 'success'; |
|
| 289 | + $message = 'Data deleted successfully'; |
|
| 290 | + } catch (Exception $e) {
|
|
| 291 | + $error = true; |
|
| 292 | + $statusCode = 404; |
|
| 293 | + $title = 'Error'; |
|
| 294 | + $type = 'error'; |
|
| 295 | + $message = 'Error'; |
|
| 296 | + } finally {
|
|
| 297 | + return Response::json(array( |
|
| 298 | 298 | 'error' => $error, |
| 299 | 299 | 'status' => $statusCode, |
| 300 | 300 | 'title' => $title, |
| 301 | 301 | 'type' => $type, |
| 302 | 302 | 'message' => $message |
| 303 | - )); |
|
| 304 | - } |
|
| 305 | - } |
|
| 303 | + )); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | 307 | } |
| 308 | 308 | |
@@ -60,18 +60,18 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return Response |
| 62 | 62 | */ |
| 63 | - public function store(Request $request, $version='') |
|
| 63 | + public function store(Request $request, $version = '') |
|
| 64 | 64 | {
|
| 65 | 65 | $path = \Request::path(); |
| 66 | 66 | $explode = explode('/', $path);
|
| 67 | 67 | |
| 68 | 68 | $from = 'form'; |
| 69 | - if(in_array('api',$explode)){
|
|
| 69 | + if (in_array('api', $explode)) {
|
|
| 70 | 70 | $from = 'api'; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $via = $from; |
| 74 | - if($version != '' && $version != 'store'){
|
|
| 74 | + if ($version != '' && $version != 'store') {
|
|
| 75 | 75 | $via .= '-'.$version; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $data = EpormasCategory::whereNull('deleted_at')
|
| 92 | 92 | ->where('name', $request->name)
|
| 93 | 93 | ->count(); |
| 94 | - if($data > 0){
|
|
| 94 | + if ($data > 0) {
|
|
| 95 | 95 | return response()->json([ |
| 96 | 96 | 'title' => 'Error', |
| 97 | 97 | 'type' => 'error', |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param int $id |
| 134 | 134 | * @return Response |
| 135 | 135 | */ |
| 136 | - public function show($version='', $id) |
|
| 136 | + public function show($version = '', $id) |
|
| 137 | 137 | {
|
| 138 | 138 | try {
|
| 139 | 139 | $error = false; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @param int $id |
| 202 | 202 | * @return Response |
| 203 | 203 | */ |
| 204 | - public function update(Request $request, $version='', $id) |
|
| 204 | + public function update(Request $request, $version = '', $id) |
|
| 205 | 205 | {
|
| 206 | 206 | $result = EpormasCategory::find($id); |
| 207 | 207 | |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | ]); |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if($request->name != $result->name){
|
|
| 221 | + if ($request->name != $result->name) {
|
|
| 222 | 222 | $data = EpormasCategory::whereNull('deleted_at')
|
| 223 | 223 | ->where('name', $request->name)
|
| 224 | 224 | ->count(); |
| 225 | - if($data > 0){
|
|
| 225 | + if ($data > 0) {
|
|
| 226 | 226 | return response()->json([ |
| 227 | 227 | 'title' => 'Error', |
| 228 | 228 | 'type' => 'error', |
@@ -235,12 +235,12 @@ discard block |
||
| 235 | 235 | $explode = explode('/', $path);
|
| 236 | 236 | |
| 237 | 237 | $from = 'form'; |
| 238 | - if(in_array('api',$explode)){
|
|
| 238 | + if (in_array('api', $explode)) {
|
|
| 239 | 239 | $from = 'api'; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $via = $from; |
| 243 | - if($version != '' && $version != 'update'){
|
|
| 243 | + if ($version != '' && $version != 'update') {
|
|
| 244 | 244 | $via .= '-'.$version; |
| 245 | 245 | } |
| 246 | 246 | |