@@ -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 |
@@ -239,7 +239,7 @@ |
||
239 | 239 | ->find($id); |
240 | 240 | if($result->tanggal){ |
241 | 241 | $format = date('Y-m-d', strtotime($result->tanggal)); |
242 | - }else { |
|
242 | + } else { |
|
243 | 243 | $format = 'Not Found'; |
244 | 244 | } |
245 | 245 |
@@ -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 | - $category = EpormasCategory::all(); |
|
62 | - $city = EpormasCity::all(); |
|
63 | - $error = false; |
|
64 | - $statusCode = 200; |
|
65 | - $title = 'Success'; |
|
66 | - $type = 'success'; |
|
67 | - $message = 'Success'; |
|
68 | - } catch (Exception $e) { |
|
69 | - $category = 'Not Found'; |
|
70 | - $city = 'Not Found'; |
|
71 | - $error = true; |
|
72 | - $statusCode = 404; |
|
73 | - $title = 'Error'; |
|
74 | - $type = 'error'; |
|
75 | - $message = 'Error'; |
|
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 | + $category = EpormasCategory::all(); |
|
62 | + $city = EpormasCity::all(); |
|
63 | + $error = false; |
|
64 | + $statusCode = 200; |
|
65 | + $title = 'Success'; |
|
66 | + $type = 'success'; |
|
67 | + $message = 'Success'; |
|
68 | + } catch (Exception $e) { |
|
69 | + $category = 'Not Found'; |
|
70 | + $city = 'Not Found'; |
|
71 | + $error = true; |
|
72 | + $statusCode = 404; |
|
73 | + $title = 'Error'; |
|
74 | + $type = 'error'; |
|
75 | + $message = 'Error'; |
|
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 | 'category' => $category, |
83 | 83 | 'city' => $city, |
84 | 84 | 'message' => $message |
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(array( |
|
119 | - 'title' => 'Error', |
|
120 | - 'type' => 'error', |
|
121 | - 'message' => $validator->errors()->all() |
|
122 | - )); |
|
118 | + return Response::json(array( |
|
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(array( |
|
135 | - 'title' => 'Error', |
|
136 | - 'type' => 'error', |
|
137 | - 'message' => 'Data has already been taken.' |
|
138 | - )); |
|
134 | + return Response::json(array( |
|
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(array( |
|
152 | - 'title' => 'Error', |
|
153 | - 'type' => 'error', |
|
154 | - 'message' => 'Data has already been taken.' |
|
155 | - )); |
|
151 | + return Response::json(array( |
|
152 | + 'title' => 'Error', |
|
153 | + 'type' => 'error', |
|
154 | + 'message' => 'Data has already been taken.' |
|
155 | + )); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $error = false; |
@@ -171,23 +171,23 @@ discard block |
||
171 | 171 | 'via' => $via |
172 | 172 | ]); |
173 | 173 | return Response::json(array( |
174 | - 'error' => $error, |
|
175 | - 'status' => $statusCode, |
|
176 | - 'title' => $title, |
|
177 | - 'type' => $type, |
|
178 | - 'message' => $message, |
|
179 | - 'result' => $result |
|
174 | + 'error' => $error, |
|
175 | + 'status' => $statusCode, |
|
176 | + 'title' => $title, |
|
177 | + 'type' => $type, |
|
178 | + 'message' => $message, |
|
179 | + 'result' => $result |
|
180 | 180 | )); |
181 | - } |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Display the specified resource. |
|
185 | - * |
|
186 | - * @param int $id |
|
187 | - * @return Response |
|
188 | - */ |
|
189 | - public function show($version='', $id) |
|
190 | - { |
|
183 | + /** |
|
184 | + * Display the specified resource. |
|
185 | + * |
|
186 | + * @param int $id |
|
187 | + * @return Response |
|
188 | + */ |
|
189 | + public function show($version='', $id) |
|
190 | + { |
|
191 | 191 | try { |
192 | 192 | $error = false; |
193 | 193 | $statusCode = 200; |
@@ -207,24 +207,24 @@ discard block |
||
207 | 207 | $result = 'Not Found'; |
208 | 208 | } finally { |
209 | 209 | return Response::json(array( |
210 | - 'error' => $error, |
|
211 | - 'status' => $statusCode, |
|
212 | - 'title' => $title, |
|
213 | - 'type' => $type, |
|
214 | - 'message' => $message, |
|
215 | - 'result' => $result |
|
210 | + 'error' => $error, |
|
211 | + 'status' => $statusCode, |
|
212 | + 'title' => $title, |
|
213 | + 'type' => $type, |
|
214 | + 'message' => $message, |
|
215 | + 'result' => $result |
|
216 | 216 | )); |
217 | 217 | } |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
221 | - * Show the form for editing the specified resource. |
|
222 | - * |
|
223 | - * @param int $id |
|
224 | - * @return Response |
|
225 | - */ |
|
226 | - public function edit($id) |
|
227 | - { |
|
220 | + /** |
|
221 | + * Show the form for editing the specified resource. |
|
222 | + * |
|
223 | + * @param int $id |
|
224 | + * @return Response |
|
225 | + */ |
|
226 | + public function edit($id) |
|
227 | + { |
|
228 | 228 | try { |
229 | 229 | $category = EpormasCategory::all(); |
230 | 230 | $city = EpormasCity::all(); |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | ->with('getCategory') |
239 | 239 | ->find($id); |
240 | 240 | if($result->tanggal){ |
241 | - $format = date('Y-m-d', strtotime($result->tanggal)); |
|
241 | + $format = date('Y-m-d', strtotime($result->tanggal)); |
|
242 | 242 | }else { |
243 | - $format = 'Not Found'; |
|
243 | + $format = 'Not Found'; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | } catch (Exception $e) { |
@@ -255,27 +255,27 @@ discard block |
||
255 | 255 | $format = 'Not Found'; |
256 | 256 | } finally { |
257 | 257 | return Response::json(array( |
258 | - 'error' => $error, |
|
259 | - 'status' => $statusCode, |
|
260 | - 'title' => $title, |
|
261 | - 'type' => $type, |
|
262 | - 'message' => $message, |
|
263 | - 'city' => $city, |
|
264 | - 'category' => $category, |
|
265 | - 'tanggal' => $format, |
|
266 | - 'result' => $result |
|
258 | + 'error' => $error, |
|
259 | + 'status' => $statusCode, |
|
260 | + 'title' => $title, |
|
261 | + 'type' => $type, |
|
262 | + 'message' => $message, |
|
263 | + 'city' => $city, |
|
264 | + 'category' => $category, |
|
265 | + 'tanggal' => $format, |
|
266 | + 'result' => $result |
|
267 | 267 | )); |
268 | 268 | } |
269 | - } |
|
269 | + } |
|
270 | 270 | |
271 | - /** |
|
272 | - * Update the specified resource in storage. |
|
273 | - * |
|
274 | - * @param int $id |
|
275 | - * @return Response |
|
276 | - */ |
|
277 | - public function update(Request $request, $version='', $id) |
|
278 | - { |
|
271 | + /** |
|
272 | + * Update the specified resource in storage. |
|
273 | + * |
|
274 | + * @param int $id |
|
275 | + * @return Response |
|
276 | + */ |
|
277 | + public function update(Request $request, $version='', $id) |
|
278 | + { |
|
279 | 279 | $result = EpormasCounter::whereNull('deleted_at') |
280 | 280 | ->with('getCity') |
281 | 281 | ->with('getCategory') |
@@ -290,28 +290,28 @@ discard block |
||
290 | 290 | |
291 | 291 | $validator = Validator::make($request->all(), $rules); |
292 | 292 | if ($validator->fails()) { |
293 | - return Response::json(array( |
|
294 | - 'title' => 'Error', |
|
295 | - 'type' => 'error', |
|
296 | - 'message' => $validator->errors()->all() |
|
297 | - )); |
|
293 | + return Response::json(array( |
|
294 | + 'title' => 'Error', |
|
295 | + 'type' => 'error', |
|
296 | + 'message' => $validator->errors()->all() |
|
297 | + )); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal))); |
301 | 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') |
|
307 | - ->orderBy('bulan') |
|
308 | - ->count(); |
|
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 | + ->orderBy('bulan') |
|
308 | + ->count(); |
|
309 | 309 | if($resultcek > 0){ |
310 | - return Response::json(array( |
|
311 | - 'title' => 'Error', |
|
312 | - 'type' => 'error', |
|
313 | - 'message' => 'Data has already been taken.' |
|
314 | - )); |
|
310 | + return Response::json(array( |
|
311 | + 'title' => 'Error', |
|
312 | + 'type' => 'error', |
|
313 | + 'message' => 'Data has already been taken.' |
|
314 | + )); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
@@ -319,34 +319,34 @@ discard block |
||
319 | 319 | $dates = date('Y-m-d', strtotime($result->tanggal)); |
320 | 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') |
|
326 | - ->orderBy('bulan') |
|
327 | - ->count(); |
|
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 | + ->orderBy('bulan') |
|
327 | + ->count(); |
|
328 | 328 | if($resultcek > 0){ |
329 | - return Response::json(array( |
|
330 | - 'title' => 'Error', |
|
331 | - 'type' => 'error', |
|
332 | - 'message' => 'Data has already been taken.' |
|
333 | - )); |
|
329 | + return Response::json(array( |
|
330 | + 'title' => 'Error', |
|
331 | + 'type' => 'error', |
|
332 | + 'message' => 'Data has already been taken.' |
|
333 | + )); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $data = EpormasCounter::whereNull('deleted_at') |
337 | - ->where('tahun', $date[0]) |
|
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') |
|
342 | - ->orderBy('bulan') |
|
343 | - ->count(); |
|
337 | + ->where('tahun', $date[0]) |
|
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') |
|
342 | + ->orderBy('bulan') |
|
343 | + ->count(); |
|
344 | 344 | if($data > 0){ |
345 | - return Response::json(array( |
|
346 | - 'title' => 'Error', |
|
347 | - 'type' => 'error', |
|
348 | - 'message' => 'Data has already been taken.' |
|
349 | - )); |
|
345 | + return Response::json(array( |
|
346 | + 'title' => 'Error', |
|
347 | + 'type' => 'error', |
|
348 | + 'message' => 'Data has already been taken.' |
|
349 | + )); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
@@ -356,13 +356,13 @@ discard block |
||
356 | 356 | $from = $result->via; |
357 | 357 | $user_id = $result->user_id; |
358 | 358 | if(in_array('api',$explode)){ |
359 | - $from = 'api'; |
|
360 | - $user_id = $request->user_id; |
|
359 | + $from = 'api'; |
|
360 | + $user_id = $request->user_id; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | $via = $from; |
364 | 364 | if($version != '' && $version != 'update'){ |
365 | - $via .= '-'.$version; |
|
365 | + $via .= '-'.$version; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | $error = false; |
@@ -381,37 +381,37 @@ discard block |
||
381 | 381 | 'via' => $via |
382 | 382 | ]); |
383 | 383 | return Response::json(array( |
384 | - 'error' => $error, |
|
385 | - 'status' => $statusCode, |
|
386 | - 'title' => $title, |
|
387 | - 'type' => $type, |
|
388 | - 'message' => $message, |
|
389 | - 'result' => $result |
|
384 | + 'error' => $error, |
|
385 | + 'status' => $statusCode, |
|
386 | + 'title' => $title, |
|
387 | + 'type' => $type, |
|
388 | + 'message' => $message, |
|
389 | + 'result' => $result |
|
390 | 390 | )); |
391 | - } |
|
391 | + } |
|
392 | 392 | |
393 | - /** |
|
394 | - * Remove the specified resource from storage. |
|
395 | - * |
|
396 | - * @param int $id |
|
397 | - * @return Response |
|
398 | - */ |
|
399 | - public function destroy($id) |
|
400 | - { |
|
401 | - EpormasCounter::find($id)->delete(); |
|
402 | - $error = false; |
|
403 | - $statusCode = 200; |
|
404 | - $title = 'Success'; |
|
405 | - $type = 'success'; |
|
406 | - $message = 'Data deleted successfully'; |
|
407 | - return Response::json(array( |
|
393 | + /** |
|
394 | + * Remove the specified resource from storage. |
|
395 | + * |
|
396 | + * @param int $id |
|
397 | + * @return Response |
|
398 | + */ |
|
399 | + public function destroy($id) |
|
400 | + { |
|
401 | + EpormasCounter::find($id)->delete(); |
|
402 | + $error = false; |
|
403 | + $statusCode = 200; |
|
404 | + $title = 'Success'; |
|
405 | + $type = 'success'; |
|
406 | + $message = 'Data deleted successfully'; |
|
407 | + return Response::json(array( |
|
408 | 408 | 'error' => $error, |
409 | 409 | 'status' => $statusCode, |
410 | 410 | 'title' => $title, |
411 | 411 | 'type' => $type, |
412 | 412 | 'message' => $message |
413 | - )); |
|
414 | - } |
|
413 | + )); |
|
414 | + } |
|
415 | 415 | |
416 | 416 | } |
417 | 417 |