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