@@ -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,20 +122,20 @@ discard block |
||
| 122 | 122 | )); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if($request->tanggal){
|
|
| 126 | - $formats = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
|
| 125 | + if ($request->tanggal) {
|
|
| 126 | + $formats = date('Y-m-d', strtotime(str_replace(' ', '-', $request->tanggal)));
|
|
| 127 | 127 | }else {
|
| 128 | 128 | $formats = ''; |
| 129 | 129 | } |
| 130 | 130 | $format = $formats; |
| 131 | 131 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 132 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 133 | - ->where('category_id',$request->category_id)
|
|
| 134 | - ->where('city_id',$request->city_id)
|
|
| 135 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 132 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 133 | + ->where('category_id', $request->category_id)
|
|
| 134 | + ->where('city_id', $request->city_id)
|
|
| 135 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 136 | 136 | ->orderBy('bulan')
|
| 137 | 137 | ->count(); |
| 138 | - if($resultcek > 0){
|
|
| 138 | + if ($resultcek > 0) {
|
|
| 139 | 139 | return Response::json(array( |
| 140 | 140 | 'title' => 'Error', |
| 141 | 141 | 'type' => 'error', |
@@ -143,16 +143,16 @@ discard block |
||
| 143 | 143 | )); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $date = explode("-",$format);
|
|
| 146 | + $date = explode("-", $format);
|
|
| 147 | 147 | $data = EpormasCounter::whereNull('deleted_at')
|
| 148 | 148 | ->where('tahun', $date[0])
|
| 149 | 149 | ->where('bulan', $date[1])
|
| 150 | - ->where('category_id',$request->category_id)
|
|
| 151 | - ->where('city_id',$request->city_id)
|
|
| 152 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 150 | + ->where('category_id', $request->category_id)
|
|
| 151 | + ->where('city_id', $request->city_id)
|
|
| 152 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 153 | 153 | ->orderBy('bulan')
|
| 154 | 154 | ->count(); |
| 155 | - if($data > 0){
|
|
| 155 | + if ($data > 0) {
|
|
| 156 | 156 | return Response::json(array( |
| 157 | 157 | 'title' => 'Error', |
| 158 | 158 | 'type' => 'error', |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @param int $id |
| 192 | 192 | * @return Response |
| 193 | 193 | */ |
| 194 | - public function show($version='', $id) |
|
| 194 | + public function show($version = '', $id) |
|
| 195 | 195 | {
|
| 196 | 196 | try {
|
| 197 | 197 | $error = false; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | ->with('getCity')
|
| 243 | 243 | ->with('getCategory')
|
| 244 | 244 | ->find($id); |
| 245 | - if($result->tanggal){
|
|
| 245 | + if ($result->tanggal) {
|
|
| 246 | 246 | $formats = date('Y-m-d', strtotime($result->tanggal));
|
| 247 | 247 | }else {
|
| 248 | 248 | $formats = 'Not Found'; |
@@ -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,21 +302,21 @@ discard block |
||
| 302 | 302 | )); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if($request->tanggal){
|
|
| 306 | - $formats = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
|
| 305 | + if ($request->tanggal) {
|
|
| 306 | + $formats = date('Y-m-d', strtotime(str_replace(' ', '-', $request->tanggal)));
|
|
| 307 | 307 | }else {
|
| 308 | 308 | $formats = ''; |
| 309 | 309 | } |
| 310 | 310 | $format = $formats; |
| 311 | - if($result->city_id != $request->city_id || $result->category_id != $request->category_id){
|
|
| 311 | + if ($result->city_id != $request->city_id || $result->category_id != $request->category_id) {
|
|
| 312 | 312 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 313 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 314 | - ->where('category_id',$request->category_id)
|
|
| 315 | - ->where('city_id',$request->city_id)
|
|
| 316 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 313 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 314 | + ->where('category_id', $request->category_id)
|
|
| 315 | + ->where('city_id', $request->city_id)
|
|
| 316 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 317 | 317 | ->orderBy('bulan')
|
| 318 | 318 | ->count(); |
| 319 | - if($resultcek > 0){
|
|
| 319 | + if ($resultcek > 0) {
|
|
| 320 | 320 | return Response::json(array( |
| 321 | 321 | 'title' => 'Error', |
| 322 | 322 | 'type' => 'error', |
@@ -325,17 +325,17 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - $date = explode("-",$format);
|
|
| 328 | + $date = explode("-", $format);
|
|
| 329 | 329 | $dates = date('Y-m-d', strtotime($result->tanggal));
|
| 330 | - if($dates != $format){
|
|
| 330 | + if ($dates != $format) {
|
|
| 331 | 331 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 332 | - ->where('category_id',$request->category_id)
|
|
| 333 | - ->where('city_id',$request->city_id)
|
|
| 334 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 335 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 332 | + ->where('category_id', $request->category_id)
|
|
| 333 | + ->where('city_id', $request->city_id)
|
|
| 334 | + ->where('tanggal', 'like', '%'.$format.'%')
|
|
| 335 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 336 | 336 | ->orderBy('bulan')
|
| 337 | 337 | ->count(); |
| 338 | - if($resultcek > 0){
|
|
| 338 | + if ($resultcek > 0) {
|
|
| 339 | 339 | return Response::json(array( |
| 340 | 340 | 'title' => 'Error', |
| 341 | 341 | 'type' => 'error', |
@@ -346,12 +346,12 @@ discard block |
||
| 346 | 346 | $data = EpormasCounter::whereNull('deleted_at')
|
| 347 | 347 | ->where('tahun', $date[0])
|
| 348 | 348 | ->where('bulan', $date[1])
|
| 349 | - ->where('category_id',$request->category_id)
|
|
| 350 | - ->where('city_id',$request->city_id)
|
|
| 351 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 349 | + ->where('category_id', $request->category_id)
|
|
| 350 | + ->where('city_id', $request->city_id)
|
|
| 351 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id')
|
|
| 352 | 352 | ->orderBy('bulan')
|
| 353 | 353 | ->count(); |
| 354 | - if($data > 0){
|
|
| 354 | + if ($data > 0) {
|
|
| 355 | 355 | return Response::json(array( |
| 356 | 356 | 'title' => 'Error', |
| 357 | 357 | 'type' => 'error', |
@@ -365,13 +365,13 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | $from = $result->via; |
| 367 | 367 | $user_id = $result->user_id; |
| 368 | - if(in_array('api',$explode)){
|
|
| 368 | + if (in_array('api', $explode)) {
|
|
| 369 | 369 | $from = 'api'; |
| 370 | 370 | $user_id = $request->user_id; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | $via = $from; |
| 374 | - if($version != '' && $version != 'update'){
|
|
| 374 | + if ($version != '' && $version != 'update') {
|
|
| 375 | 375 | $via .= '-'.$version; |
| 376 | 376 | } |
| 377 | 377 | |