@@ -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(array( |
| 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(array( |
| 152 | 152 | 'title' => 'Error', |
| 153 | 153 | 'type' => 'error', |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @param int $id |
| 187 | 187 | * @return Response |
| 188 | 188 | */ |
| 189 | - public function show($version='', $id) |
|
| 189 | + public function show($version = '', $id) |
|
| 190 | 190 | {
|
| 191 | 191 | try {
|
| 192 | 192 | $error = false; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | ->with('getCity')
|
| 238 | 238 | ->with('getCategory')
|
| 239 | 239 | ->find($id); |
| 240 | - if($result->tanggal){
|
|
| 240 | + if ($result->tanggal) {
|
|
| 241 | 241 | $format = date('Y-m-d', strtotime($result->tanggal));
|
| 242 | 242 | }else {
|
| 243 | 243 | $format = 'Not Found'; |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * @param int $id |
| 275 | 275 | * @return Response |
| 276 | 276 | */ |
| 277 | - public function update(Request $request, $version='', $id) |
|
| 277 | + public function update(Request $request, $version = '', $id) |
|
| 278 | 278 | {
|
| 279 | 279 | $result = EpormasCounter::whereNull('deleted_at')
|
| 280 | 280 | ->with('getCity')
|
@@ -297,16 +297,16 @@ discard block |
||
| 297 | 297 | )); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
|
| 301 | - if($result->city_id != $request->city_id || $result->category_id != $request->category_id){
|
|
| 300 | + $format = date('Y-m-d', strtotime(str_replace(' ', '-', $request->tanggal)));
|
|
| 301 | + if ($result->city_id != $request->city_id || $result->category_id != $request->category_id) {
|
|
| 302 | 302 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 303 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 304 | - ->where('category_id',$request->category_id)
|
|
| 305 | - ->where('city_id',$request->city_id)
|
|
| 306 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 303 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 304 | + ->where('category_id', $request->category_id)
|
|
| 305 | + ->where('city_id', $request->city_id)
|
|
| 306 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 307 | 307 | ->orderBy('bulan')
|
| 308 | 308 | ->count(); |
| 309 | - if($resultcek > 0){
|
|
| 309 | + if ($resultcek > 0) {
|
|
| 310 | 310 | return Response::json(array( |
| 311 | 311 | 'title' => 'Error', |
| 312 | 312 | 'type' => 'error', |
@@ -315,17 +315,17 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $date = explode("-",$format);
|
|
| 318 | + $date = explode("-", $format);
|
|
| 319 | 319 | $dates = date('Y-m-d', strtotime($result->tanggal));
|
| 320 | - if($dates != $format){
|
|
| 320 | + if ($dates != $format) {
|
|
| 321 | 321 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 322 | - ->where('category_id',$request->category_id)
|
|
| 323 | - ->where('city_id',$request->city_id)
|
|
| 324 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 325 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 322 | + ->where('category_id', $request->category_id)
|
|
| 323 | + ->where('city_id', $request->city_id)
|
|
| 324 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 325 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 326 | 326 | ->orderBy('bulan')
|
| 327 | 327 | ->count(); |
| 328 | - if($resultcek > 0){
|
|
| 328 | + if ($resultcek > 0) {
|
|
| 329 | 329 | return Response::json(array( |
| 330 | 330 | 'title' => 'Error', |
| 331 | 331 | 'type' => 'error', |
@@ -336,12 +336,12 @@ discard block |
||
| 336 | 336 | $data = EpormasCounter::whereNull('deleted_at')
|
| 337 | 337 | ->where('tahun', $date[0])
|
| 338 | 338 | ->where('bulan', $date[1])
|
| 339 | - ->where('category_id',$request->category_id)
|
|
| 340 | - ->where('city_id',$request->city_id)
|
|
| 341 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 339 | + ->where('category_id', $request->category_id)
|
|
| 340 | + ->where('city_id', $request->city_id)
|
|
| 341 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 342 | 342 | ->orderBy('bulan')
|
| 343 | 343 | ->count(); |
| 344 | - if($data > 0){
|
|
| 344 | + if ($data > 0) {
|
|
| 345 | 345 | return Response::json(array( |
| 346 | 346 | 'title' => 'Error', |
| 347 | 347 | 'type' => 'error', |
@@ -355,13 +355,13 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | $from = $result->via; |
| 357 | 357 | $user_id = $result->user_id; |
| 358 | - if(in_array('api',$explode)){
|
|
| 358 | + if (in_array('api', $explode)) {
|
|
| 359 | 359 | $from = 'api'; |
| 360 | 360 | $user_id = $request->user_id; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $via = $from; |
| 364 | - if($version != '' && $version != 'update'){
|
|
| 364 | + if ($version != '' && $version != 'update') {
|
|
| 365 | 365 | $via .= '-'.$version; |
| 366 | 366 | } |
| 367 | 367 | |