@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return Response |
69 | 69 | */ |
70 | - public function store(Request $request, $version='') |
|
70 | + public function store(Request $request, $version = '') |
|
71 | 71 | { |
72 | 72 | $path = \Request::path(); |
73 | 73 | $explode = explode('/', $path); |
74 | 74 | |
75 | 75 | $from = 'form'; |
76 | - if(in_array('api',$explode)){ |
|
76 | + if (in_array('api', $explode)) { |
|
77 | 77 | $from = 'api'; |
78 | 78 | } |
79 | 79 | |
80 | 80 | $via = $from; |
81 | - if($version != '' && $version != 'store'){ |
|
81 | + if ($version != '' && $version != 'store') { |
|
82 | 82 | $via .= '-'.$version; |
83 | 83 | } |
84 | 84 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $data = EpormasCategory::whereNull('deleted_at') |
99 | 99 | ->where('name', $request->name) |
100 | 100 | ->count(); |
101 | - if($data > 0){ |
|
101 | + if ($data > 0) { |
|
102 | 102 | return Response::json(array( |
103 | 103 | 'title' => 'Error', |
104 | 104 | 'type' => 'error', |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param int $id |
148 | 148 | * @return Response |
149 | 149 | */ |
150 | - public function show($version='', $id) |
|
150 | + public function show($version = '', $id) |
|
151 | 151 | { |
152 | 152 | try { |
153 | 153 | $error = false; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param int $id |
230 | 230 | * @return Response |
231 | 231 | */ |
232 | - public function update(Request $request, $version='', $id) |
|
232 | + public function update(Request $request, $version = '', $id) |
|
233 | 233 | { |
234 | 234 | $result = EpormasCategory::find($id); |
235 | 235 | |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | )); |
246 | 246 | } |
247 | 247 | |
248 | - if($request->name != $result->name){ |
|
248 | + if ($request->name != $result->name) { |
|
249 | 249 | $data = EpormasCategory::whereNull('deleted_at') |
250 | 250 | ->where('name', $request->name) |
251 | 251 | ->count(); |
252 | - if($data > 0){ |
|
252 | + if ($data > 0) { |
|
253 | 253 | return Response::json(array( |
254 | 254 | 'title' => 'Error', |
255 | 255 | 'type' => 'error', |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | $explode = explode('/', $path); |
263 | 263 | |
264 | 264 | $from = 'form'; |
265 | - if(in_array('api',$explode)){ |
|
265 | + if (in_array('api', $explode)) { |
|
266 | 266 | $from = 'api'; |
267 | 267 | } |
268 | 268 | |
269 | 269 | $via = $from; |
270 | - if($version != '' && $version != 'update'){ |
|
270 | + if ($version != '' && $version != 'update') { |
|
271 | 271 | $via .= '-'.$version; |
272 | 272 | } |
273 | 273 |
@@ -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(array( |
|
85 | - 'title' => 'Error', |
|
86 | - 'type' => 'error', |
|
87 | - 'message' => $validator->errors()->all() |
|
88 | - )); |
|
84 | + return Response::json(array( |
|
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(array( |
|
96 | - 'title' => 'Error', |
|
97 | - 'type' => 'error', |
|
98 | - 'message' => 'Data has already been taken.' |
|
99 | - )); |
|
95 | + return Response::json(array( |
|
96 | + 'title' => 'Error', |
|
97 | + 'type' => 'error', |
|
98 | + 'message' => 'Data has already been taken.' |
|
99 | + )); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $error = false; |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | 'name' => $request->name |
109 | 109 | ]); |
110 | 110 | return Response::json(array( |
111 | - 'error' => $error, |
|
112 | - 'status' => $statusCode, |
|
113 | - 'title' => $title, |
|
114 | - 'type' => $type, |
|
115 | - 'message' => $message, |
|
116 | - 'result' => $result |
|
111 | + 'error' => $error, |
|
112 | + 'status' => $statusCode, |
|
113 | + 'title' => $title, |
|
114 | + 'type' => $type, |
|
115 | + 'message' => $message, |
|
116 | + 'result' => $result |
|
117 | 117 | )); |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Display the specified resource. |
|
122 | - * |
|
123 | - * @param int $id |
|
124 | - * @return Response |
|
125 | - */ |
|
126 | - public function show($version='', $id) |
|
127 | - { |
|
120 | + /** |
|
121 | + * Display the specified resource. |
|
122 | + * |
|
123 | + * @param int $id |
|
124 | + * @return Response |
|
125 | + */ |
|
126 | + public function show($version='', $id) |
|
127 | + { |
|
128 | 128 | try { |
129 | 129 | $error = false; |
130 | 130 | $statusCode = 200; |
@@ -141,24 +141,24 @@ discard block |
||
141 | 141 | $result = 'Not Found'; |
142 | 142 | } finally { |
143 | 143 | return Response::json(array( |
144 | - 'error' => $error, |
|
145 | - 'status' => $statusCode, |
|
146 | - 'title' => $title, |
|
147 | - 'type' => $type, |
|
148 | - 'message' => $message, |
|
149 | - 'result' => $result |
|
144 | + 'error' => $error, |
|
145 | + 'status' => $statusCode, |
|
146 | + 'title' => $title, |
|
147 | + 'type' => $type, |
|
148 | + 'message' => $message, |
|
149 | + 'result' => $result |
|
150 | 150 | )); |
151 | 151 | } |
152 | - } |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Show the form for editing the specified resource. |
|
156 | - * |
|
157 | - * @param int $id |
|
158 | - * @return Response |
|
159 | - */ |
|
160 | - public function edit($id) |
|
161 | - { |
|
154 | + /** |
|
155 | + * Show the form for editing the specified resource. |
|
156 | + * |
|
157 | + * @param int $id |
|
158 | + * @return Response |
|
159 | + */ |
|
160 | + public function edit($id) |
|
161 | + { |
|
162 | 162 | try { |
163 | 163 | $error = false; |
164 | 164 | $statusCode = 200; |
@@ -175,24 +175,24 @@ discard block |
||
175 | 175 | $result = 'Not Found'; |
176 | 176 | } finally { |
177 | 177 | return Response::json(array( |
178 | - 'error' => $error, |
|
179 | - 'status' => $statusCode, |
|
180 | - 'title' => $title, |
|
181 | - 'type' => $type, |
|
182 | - 'message' => $message, |
|
183 | - 'result' => $result |
|
178 | + 'error' => $error, |
|
179 | + 'status' => $statusCode, |
|
180 | + 'title' => $title, |
|
181 | + 'type' => $type, |
|
182 | + 'message' => $message, |
|
183 | + 'result' => $result |
|
184 | 184 | )); |
185 | 185 | } |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * Update the specified resource in storage. |
|
190 | - * |
|
191 | - * @param int $id |
|
192 | - * @return Response |
|
193 | - */ |
|
194 | - public function update(Request $request, $version='', $id) |
|
195 | - { |
|
188 | + /** |
|
189 | + * Update the specified resource in storage. |
|
190 | + * |
|
191 | + * @param int $id |
|
192 | + * @return Response |
|
193 | + */ |
|
194 | + public function update(Request $request, $version='', $id) |
|
195 | + { |
|
196 | 196 | $result = EpormasCategory::find($id); |
197 | 197 | |
198 | 198 | $rules = [ |
@@ -201,23 +201,23 @@ discard block |
||
201 | 201 | |
202 | 202 | $validator = Validator::make($request->all(), $rules); |
203 | 203 | if ($validator->fails()) { |
204 | - return Response::json(array( |
|
205 | - 'type' => 'error', |
|
206 | - 'message' => $validator->errors()->all() |
|
207 | - )); |
|
204 | + return Response::json(array( |
|
205 | + 'type' => 'error', |
|
206 | + 'message' => $validator->errors()->all() |
|
207 | + )); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | if($request->name != $result->name){ |
211 | - $data = EpormasCategory::whereNull('deleted_at') |
|
212 | - ->where('name', $request->name) |
|
213 | - ->count(); |
|
214 | - if($data > 0){ |
|
211 | + $data = EpormasCategory::whereNull('deleted_at') |
|
212 | + ->where('name', $request->name) |
|
213 | + ->count(); |
|
214 | + if($data > 0){ |
|
215 | 215 | return Response::json(array( |
216 | 216 | 'title' => 'Error', |
217 | 217 | 'type' => 'error', |
218 | 218 | 'message' => 'Data has already been taken.' |
219 | 219 | )); |
220 | - } |
|
220 | + } |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | $path = \Request::path(); |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | |
226 | 226 | $from = 'form'; |
227 | 227 | if(in_array('api',$explode)){ |
228 | - $from = 'api'; |
|
228 | + $from = 'api'; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $via = $from; |
232 | 232 | if($version != '' && $version != 'update'){ |
233 | - $via .= '-'.$version; |
|
233 | + $via .= '-'.$version; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | $error = false; |
@@ -242,37 +242,37 @@ discard block |
||
242 | 242 | 'name' => $request->name |
243 | 243 | ]); |
244 | 244 | return Response::json(array( |
245 | - 'error' => $error, |
|
246 | - 'status' => $statusCode, |
|
247 | - 'title' => $title, |
|
248 | - 'type' => $type, |
|
249 | - 'message' => $message, |
|
250 | - 'result' => $result |
|
245 | + 'error' => $error, |
|
246 | + 'status' => $statusCode, |
|
247 | + 'title' => $title, |
|
248 | + 'type' => $type, |
|
249 | + 'message' => $message, |
|
250 | + 'result' => $result |
|
251 | 251 | )); |
252 | - } |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * Remove the specified resource from storage. |
|
256 | - * |
|
257 | - * @param int $id |
|
258 | - * @return Response |
|
259 | - */ |
|
260 | - public function destroy($id) |
|
261 | - { |
|
262 | - EpormasCategory::find($id)->delete(); |
|
263 | - $error = false; |
|
264 | - $statusCode = 200; |
|
265 | - $title = 'Success'; |
|
266 | - $type = 'success'; |
|
267 | - $message = 'Data deleted successfully'; |
|
268 | - return Response::json(array( |
|
254 | + /** |
|
255 | + * Remove the specified resource from storage. |
|
256 | + * |
|
257 | + * @param int $id |
|
258 | + * @return Response |
|
259 | + */ |
|
260 | + public function destroy($id) |
|
261 | + { |
|
262 | + EpormasCategory::find($id)->delete(); |
|
263 | + $error = false; |
|
264 | + $statusCode = 200; |
|
265 | + $title = 'Success'; |
|
266 | + $type = 'success'; |
|
267 | + $message = 'Data deleted successfully'; |
|
268 | + return Response::json(array( |
|
269 | 269 | 'error' => $error, |
270 | 270 | 'status' => $statusCode, |
271 | 271 | 'title' => $title, |
272 | 272 | 'type' => $type, |
273 | 273 | 'message' => $message |
274 | - )); |
|
275 | - } |
|
274 | + )); |
|
275 | + } |
|
276 | 276 | |
277 | 277 | } |
278 | 278 |
@@ -106,18 +106,18 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return Response |
108 | 108 | */ |
109 | - public function store(Request $request, $version='') |
|
109 | + public function store(Request $request, $version = '') |
|
110 | 110 | { |
111 | 111 | $path = \Request::path(); |
112 | 112 | $explode = explode('/', $path); |
113 | 113 | |
114 | 114 | $from = 'form'; |
115 | - if(in_array('api',$explode)){ |
|
115 | + if (in_array('api', $explode)) { |
|
116 | 116 | $from = 'api'; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $via = $from; |
120 | - if($version != '' && $version != 'store'){ |
|
120 | + if ($version != '' && $version != 'store') { |
|
121 | 121 | $via .= '-'.$version; |
122 | 122 | } |
123 | 123 | |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | )); |
138 | 138 | } |
139 | 139 | |
140 | - $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal))); |
|
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') |
|
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 | 146 | ->orderBy('bulan') |
147 | 147 | ->count(); |
148 | - if($resultcek > 0){ |
|
148 | + if ($resultcek > 0) { |
|
149 | 149 | return Response::json(array( |
150 | 150 | 'title' => 'Error', |
151 | 151 | 'type' => 'error', |
@@ -153,16 +153,16 @@ discard block |
||
153 | 153 | )); |
154 | 154 | } |
155 | 155 | |
156 | - $date = explode("-",$format); |
|
156 | + $date = explode("-", $format); |
|
157 | 157 | $data = EpormasCounter::whereNull('deleted_at') |
158 | 158 | ->where('tahun', $date[0]) |
159 | 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') |
|
160 | + ->where('category_id', $request->category_id) |
|
161 | + ->where('city_id', $request->city_id) |
|
162 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id') |
|
163 | 163 | ->orderBy('bulan') |
164 | 164 | ->count(); |
165 | - if($data > 0){ |
|
165 | + if ($data > 0) { |
|
166 | 166 | return Response::json(array( |
167 | 167 | 'title' => 'Error', |
168 | 168 | 'type' => 'error', |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param int $id |
219 | 219 | * @return Response |
220 | 220 | */ |
221 | - public function show($version='', $id) |
|
221 | + public function show($version = '', $id) |
|
222 | 222 | { |
223 | 223 | try { |
224 | 224 | $error = false; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @param int $id |
319 | 319 | * @return Response |
320 | 320 | */ |
321 | - public function update(Request $request, $version='', $id) |
|
321 | + public function update(Request $request, $version = '', $id) |
|
322 | 322 | { |
323 | 323 | $result = EpormasCounter::whereNull('deleted_at') |
324 | 324 | ->with('getCity') |
@@ -341,16 +341,16 @@ discard block |
||
341 | 341 | )); |
342 | 342 | } |
343 | 343 | |
344 | - $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal))); |
|
345 | - if($result->city_id != $request->city_id || $result->category_id != $request->category_id){ |
|
344 | + $format = date('Y-m-d', strtotime(str_replace(' ', '-', $request->tanggal))); |
|
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') |
|
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 | 351 | ->orderBy('bulan') |
352 | 352 | ->count(); |
353 | - if($resultcek > 0){ |
|
353 | + if ($resultcek > 0) { |
|
354 | 354 | return Response::json(array( |
355 | 355 | 'title' => 'Error', |
356 | 356 | 'type' => 'error', |
@@ -359,17 +359,17 @@ discard block |
||
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | - $date = explode("-",$format); |
|
362 | + $date = explode("-", $format); |
|
363 | 363 | $dates = date('Y-m-d', strtotime($result->tanggal)); |
364 | - if($dates != $format){ |
|
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') |
|
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 | 370 | ->orderBy('bulan') |
371 | 371 | ->count(); |
372 | - if($resultcek > 0){ |
|
372 | + if ($resultcek > 0) { |
|
373 | 373 | return Response::json(array( |
374 | 374 | 'title' => 'Error', |
375 | 375 | 'type' => 'error', |
@@ -380,12 +380,12 @@ discard block |
||
380 | 380 | $data = EpormasCounter::whereNull('deleted_at') |
381 | 381 | ->where('tahun', $date[0]) |
382 | 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') |
|
383 | + ->where('category_id', $request->category_id) |
|
384 | + ->where('city_id', $request->city_id) |
|
385 | + ->groupBy('tahun', 'bulan', 'category_id', 'city_id') |
|
386 | 386 | ->orderBy('bulan') |
387 | 387 | ->count(); |
388 | - if($data > 0){ |
|
388 | + if ($data > 0) { |
|
389 | 389 | return Response::json(array( |
390 | 390 | 'title' => 'Error', |
391 | 391 | 'type' => 'error', |
@@ -399,13 +399,13 @@ discard block |
||
399 | 399 | |
400 | 400 | $from = $result->via; |
401 | 401 | $user_id = $result->user_id; |
402 | - if(in_array('api',$explode)){ |
|
402 | + if (in_array('api', $explode)) { |
|
403 | 403 | $from = 'api'; |
404 | 404 | $user_id = $request->user_id; |
405 | 405 | } |
406 | 406 | |
407 | 407 | $via = $from; |
408 | - if($version != '' && $version != 'update'){ |
|
408 | + if ($version != '' && $version != 'update') { |
|
409 | 409 | $via .= '-'.$version; |
410 | 410 | } |
411 | 411 |
@@ -14,69 +14,69 @@ 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 | - $city = EpormasCity::all(); |
|
61 | - $category = EpormasCategory::all(); |
|
62 | - try { |
|
63 | - $error = false; |
|
64 | - $statusCode = 200; |
|
65 | - $title = 'Success'; |
|
66 | - $type = 'success'; |
|
67 | - $message = 'Success'; |
|
68 | - $citys = $city; |
|
69 | - $categorys = $category; |
|
70 | - } catch (Exception $e) { |
|
71 | - $error = true; |
|
72 | - $statusCode = 404; |
|
73 | - $title = 'Error'; |
|
74 | - $type = 'error'; |
|
75 | - $message = 'Error'; |
|
76 | - $citys = 'Not Found'; |
|
77 | - $categorys = 'Not Found'; |
|
78 | - } finally { |
|
79 | - 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 | + $city = EpormasCity::all(); |
|
61 | + $category = EpormasCategory::all(); |
|
62 | + try { |
|
63 | + $error = false; |
|
64 | + $statusCode = 200; |
|
65 | + $title = 'Success'; |
|
66 | + $type = 'success'; |
|
67 | + $message = 'Success'; |
|
68 | + $citys = $city; |
|
69 | + $categorys = $category; |
|
70 | + } catch (Exception $e) { |
|
71 | + $error = true; |
|
72 | + $statusCode = 404; |
|
73 | + $title = 'Error'; |
|
74 | + $type = 'error'; |
|
75 | + $message = 'Error'; |
|
76 | + $citys = 'Not Found'; |
|
77 | + $categorys = 'Not Found'; |
|
78 | + } finally { |
|
79 | + return Response::json(array( |
|
80 | 80 | 'error' => $error, |
81 | 81 | 'status' => $statusCode, |
82 | 82 | 'title' => $title, |
@@ -84,31 +84,31 @@ discard block |
||
84 | 84 | 'message' => $message, |
85 | 85 | 'city' => $citys, |
86 | 86 | 'category' => $categorys |
87 | - )); |
|
88 | - } |
|
89 | - } |
|
87 | + )); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Store a newly created resource in storage. |
|
93 | - * |
|
94 | - * @return Response |
|
95 | - */ |
|
96 | - public function store(Request $request, $version='') |
|
97 | - { |
|
91 | + /** |
|
92 | + * Store a newly created resource in storage. |
|
93 | + * |
|
94 | + * @return Response |
|
95 | + */ |
|
96 | + public function store(Request $request, $version='') |
|
97 | + { |
|
98 | 98 | $path = \Request::path(); |
99 | 99 | $explode = explode('/', $path); |
100 | 100 | |
101 | 101 | $from = 'form'; |
102 | 102 | if(in_array('api',$explode)){ |
103 | - $from = 'api'; |
|
103 | + $from = 'api'; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $via = $from; |
107 | 107 | if($version != '' && $version != 'store'){ |
108 | - $via .= '-'.$version; |
|
108 | + $via .= '-'.$version; |
|
109 | 109 | } |
110 | 110 | |
111 | - $rules = [ |
|
111 | + $rules = [ |
|
112 | 112 | 'count' => 'required|numeric', |
113 | 113 | 'city_id' => 'required|numeric', |
114 | 114 | 'category_id' => 'required|numeric', |
@@ -117,44 +117,44 @@ discard block |
||
117 | 117 | |
118 | 118 | $validator = Validator::make($request->all(), $rules); |
119 | 119 | if ($validator->fails()) { |
120 | - return Response::json(array( |
|
121 | - 'title' => 'Error', |
|
122 | - 'type' => 'error', |
|
123 | - 'message' => $validator->errors()->all() |
|
124 | - )); |
|
120 | + return Response::json(array( |
|
121 | + 'title' => 'Error', |
|
122 | + 'type' => 'error', |
|
123 | + 'message' => $validator->errors()->all() |
|
124 | + )); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal))); |
128 | 128 | $resultcek = EpormasCounter::whereNull('deleted_at') |
129 | - ->where('tanggal','like','%'.$format.'%') |
|
130 | - ->where('category_id',$request->category_id) |
|
131 | - ->where('city_id',$request->city_id) |
|
132 | - ->groupBy('tahun','bulan','category_id','city_id') |
|
133 | - ->orderBy('bulan') |
|
134 | - ->count(); |
|
129 | + ->where('tanggal','like','%'.$format.'%') |
|
130 | + ->where('category_id',$request->category_id) |
|
131 | + ->where('city_id',$request->city_id) |
|
132 | + ->groupBy('tahun','bulan','category_id','city_id') |
|
133 | + ->orderBy('bulan') |
|
134 | + ->count(); |
|
135 | 135 | if($resultcek > 0){ |
136 | - return Response::json(array( |
|
137 | - 'title' => 'Error', |
|
138 | - 'type' => 'error', |
|
139 | - 'message' => 'Data has already been taken.' |
|
140 | - )); |
|
136 | + return Response::json(array( |
|
137 | + 'title' => 'Error', |
|
138 | + 'type' => 'error', |
|
139 | + 'message' => 'Data has already been taken.' |
|
140 | + )); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | $date = explode("-",$format); |
144 | 144 | $data = EpormasCounter::whereNull('deleted_at') |
145 | - ->where('tahun', $date[0]) |
|
146 | - ->where('bulan', $date[1]) |
|
147 | - ->where('category_id',$request->category_id) |
|
148 | - ->where('city_id',$request->city_id) |
|
149 | - ->groupBy('tahun','bulan','category_id','city_id') |
|
150 | - ->orderBy('bulan') |
|
151 | - ->count(); |
|
145 | + ->where('tahun', $date[0]) |
|
146 | + ->where('bulan', $date[1]) |
|
147 | + ->where('category_id',$request->category_id) |
|
148 | + ->where('city_id',$request->city_id) |
|
149 | + ->groupBy('tahun','bulan','category_id','city_id') |
|
150 | + ->orderBy('bulan') |
|
151 | + ->count(); |
|
152 | 152 | if($data > 0){ |
153 | - return Response::json(array( |
|
154 | - 'title' => 'Error', |
|
155 | - 'type' => 'error', |
|
156 | - 'message' => 'Data has already been taken.' |
|
157 | - )); |
|
153 | + return Response::json(array( |
|
154 | + 'title' => 'Error', |
|
155 | + 'type' => 'error', |
|
156 | + 'message' => 'Data has already been taken.' |
|
157 | + )); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | $error = false; |
@@ -173,23 +173,23 @@ discard block |
||
173 | 173 | 'via' => $via |
174 | 174 | ]); |
175 | 175 | return Response::json(array( |
176 | - 'error' => $error, |
|
177 | - 'status' => $statusCode, |
|
178 | - 'title' => $title, |
|
179 | - 'type' => $type, |
|
180 | - 'message' => $message, |
|
181 | - 'result' => $result |
|
176 | + 'error' => $error, |
|
177 | + 'status' => $statusCode, |
|
178 | + 'title' => $title, |
|
179 | + 'type' => $type, |
|
180 | + 'message' => $message, |
|
181 | + 'result' => $result |
|
182 | 182 | )); |
183 | - } |
|
183 | + } |
|
184 | 184 | |
185 | - /** |
|
186 | - * Display the specified resource. |
|
187 | - * |
|
188 | - * @param int $id |
|
189 | - * @return Response |
|
190 | - */ |
|
191 | - public function show($version='', $id) |
|
192 | - { |
|
185 | + /** |
|
186 | + * Display the specified resource. |
|
187 | + * |
|
188 | + * @param int $id |
|
189 | + * @return Response |
|
190 | + */ |
|
191 | + public function show($version='', $id) |
|
192 | + { |
|
193 | 193 | try { |
194 | 194 | $error = false; |
195 | 195 | $statusCode = 200; |
@@ -209,24 +209,24 @@ discard block |
||
209 | 209 | $result = 'Not Found'; |
210 | 210 | } finally { |
211 | 211 | return Response::json(array( |
212 | - 'error' => $error, |
|
213 | - 'status' => $statusCode, |
|
214 | - 'title' => $title, |
|
215 | - 'type' => $type, |
|
216 | - 'message' => $message, |
|
217 | - 'result' => $result |
|
212 | + 'error' => $error, |
|
213 | + 'status' => $statusCode, |
|
214 | + 'title' => $title, |
|
215 | + 'type' => $type, |
|
216 | + 'message' => $message, |
|
217 | + 'result' => $result |
|
218 | 218 | )); |
219 | 219 | } |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * Show the form for editing the specified resource. |
|
224 | - * |
|
225 | - * @param int $id |
|
226 | - * @return Response |
|
227 | - */ |
|
228 | - public function edit($id) |
|
229 | - { |
|
222 | + /** |
|
223 | + * Show the form for editing the specified resource. |
|
224 | + * |
|
225 | + * @param int $id |
|
226 | + * @return Response |
|
227 | + */ |
|
228 | + public function edit($id) |
|
229 | + { |
|
230 | 230 | $city = EpormasCity::all(); |
231 | 231 | $category = EpormasCategory::all(); |
232 | 232 | try { |
@@ -254,27 +254,27 @@ discard block |
||
254 | 254 | $format = 'Not Found'; |
255 | 255 | } finally { |
256 | 256 | return Response::json(array( |
257 | - 'error' => $error, |
|
258 | - 'status' => $statusCode, |
|
259 | - 'title' => $title, |
|
260 | - 'type' => $type, |
|
261 | - 'message' => $message, |
|
262 | - 'city' => $citys, |
|
263 | - 'category' => $categorys, |
|
264 | - 'result' => $result, |
|
265 | - 'tanggal' => $format |
|
257 | + 'error' => $error, |
|
258 | + 'status' => $statusCode, |
|
259 | + 'title' => $title, |
|
260 | + 'type' => $type, |
|
261 | + 'message' => $message, |
|
262 | + 'city' => $citys, |
|
263 | + 'category' => $categorys, |
|
264 | + 'result' => $result, |
|
265 | + 'tanggal' => $format |
|
266 | 266 | )); |
267 | 267 | } |
268 | - } |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Update the specified resource in storage. |
|
272 | - * |
|
273 | - * @param int $id |
|
274 | - * @return Response |
|
275 | - */ |
|
276 | - public function update(Request $request, $version='', $id) |
|
277 | - { |
|
270 | + /** |
|
271 | + * Update the specified resource in storage. |
|
272 | + * |
|
273 | + * @param int $id |
|
274 | + * @return Response |
|
275 | + */ |
|
276 | + public function update(Request $request, $version='', $id) |
|
277 | + { |
|
278 | 278 | $result = EpormasCounter::whereNull('deleted_at') |
279 | 279 | ->with('getCity') |
280 | 280 | ->with('getCategory') |
@@ -289,28 +289,28 @@ discard block |
||
289 | 289 | |
290 | 290 | $validator = Validator::make($request->all(), $rules); |
291 | 291 | if ($validator->fails()) { |
292 | - return Response::json(array( |
|
293 | - 'title' => 'Error', |
|
294 | - 'type' => 'error', |
|
295 | - 'message' => $validator->errors()->all() |
|
296 | - )); |
|
292 | + return Response::json(array( |
|
293 | + 'title' => 'Error', |
|
294 | + 'type' => 'error', |
|
295 | + 'message' => $validator->errors()->all() |
|
296 | + )); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal))); |
300 | 300 | if($result->city_id != $request->city_id || $result->category_id != $request->category_id){ |
301 | 301 | $resultcek = EpormasCounter::whereNull('deleted_at') |
302 | - ->where('tanggal','like','%'.$format.'%') |
|
303 | - ->where('category_id',$request->category_id) |
|
304 | - ->where('city_id',$request->city_id) |
|
305 | - ->groupBy('tahun','bulan','category_id','city_id') |
|
306 | - ->orderBy('bulan') |
|
307 | - ->count(); |
|
302 | + ->where('tanggal','like','%'.$format.'%') |
|
303 | + ->where('category_id',$request->category_id) |
|
304 | + ->where('city_id',$request->city_id) |
|
305 | + ->groupBy('tahun','bulan','category_id','city_id') |
|
306 | + ->orderBy('bulan') |
|
307 | + ->count(); |
|
308 | 308 | if($resultcek > 0){ |
309 | - return Response::json(array( |
|
310 | - 'title' => 'Error', |
|
311 | - 'type' => 'error', |
|
312 | - 'message' => 'Data has already been taken.' |
|
313 | - )); |
|
309 | + return Response::json(array( |
|
310 | + 'title' => 'Error', |
|
311 | + 'type' => 'error', |
|
312 | + 'message' => 'Data has already been taken.' |
|
313 | + )); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
@@ -318,34 +318,34 @@ discard block |
||
318 | 318 | $dates = date('Y-m-d', strtotime($result->tanggal)); |
319 | 319 | if($dates != $format){ |
320 | 320 | $resultcek = EpormasCounter::whereNull('deleted_at') |
321 | - ->where('category_id',$request->category_id) |
|
322 | - ->where('city_id',$request->city_id) |
|
323 | - ->where('tanggal','like','%'.$format.'%') |
|
324 | - ->groupBy('tahun','bulan','category_id','city_id') |
|
325 | - ->orderBy('bulan') |
|
326 | - ->count(); |
|
321 | + ->where('category_id',$request->category_id) |
|
322 | + ->where('city_id',$request->city_id) |
|
323 | + ->where('tanggal','like','%'.$format.'%') |
|
324 | + ->groupBy('tahun','bulan','category_id','city_id') |
|
325 | + ->orderBy('bulan') |
|
326 | + ->count(); |
|
327 | 327 | if($resultcek > 0){ |
328 | - return Response::json(array( |
|
329 | - 'title' => 'Error', |
|
330 | - 'type' => 'error', |
|
331 | - 'message' => 'Data has already been taken.' |
|
332 | - )); |
|
328 | + return Response::json(array( |
|
329 | + 'title' => 'Error', |
|
330 | + 'type' => 'error', |
|
331 | + 'message' => 'Data has already been taken.' |
|
332 | + )); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | $data = EpormasCounter::whereNull('deleted_at') |
336 | - ->where('tahun', $date[0]) |
|
337 | - ->where('bulan', $date[1]) |
|
338 | - ->where('category_id',$request->category_id) |
|
339 | - ->where('city_id',$request->city_id) |
|
340 | - ->groupBy('tahun','bulan','category_id','city_id') |
|
341 | - ->orderBy('bulan') |
|
342 | - ->count(); |
|
336 | + ->where('tahun', $date[0]) |
|
337 | + ->where('bulan', $date[1]) |
|
338 | + ->where('category_id',$request->category_id) |
|
339 | + ->where('city_id',$request->city_id) |
|
340 | + ->groupBy('tahun','bulan','category_id','city_id') |
|
341 | + ->orderBy('bulan') |
|
342 | + ->count(); |
|
343 | 343 | if($data > 0){ |
344 | - return Response::json(array( |
|
345 | - 'title' => 'Error', |
|
346 | - 'type' => 'error', |
|
347 | - 'message' => 'Data has already been taken.' |
|
348 | - )); |
|
344 | + return Response::json(array( |
|
345 | + 'title' => 'Error', |
|
346 | + 'type' => 'error', |
|
347 | + 'message' => 'Data has already been taken.' |
|
348 | + )); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | $from = $result->via; |
356 | 356 | $user_id = $result->user_id; |
357 | 357 | if(in_array('api',$explode)){ |
358 | - $from = 'api'; |
|
359 | - $user_id = $request->user_id; |
|
358 | + $from = 'api'; |
|
359 | + $user_id = $request->user_id; |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | $via = $from; |
363 | 363 | if($version != '' && $version != 'update'){ |
364 | - $via .= '-'.$version; |
|
364 | + $via .= '-'.$version; |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | $error = false; |
@@ -380,37 +380,37 @@ discard block |
||
380 | 380 | 'via' => $via |
381 | 381 | ]); |
382 | 382 | return Response::json(array( |
383 | - 'error' => $error, |
|
384 | - 'status' => $statusCode, |
|
385 | - 'title' => $title, |
|
386 | - 'type' => $type, |
|
387 | - 'message' => $message, |
|
388 | - 'result' => $result |
|
383 | + 'error' => $error, |
|
384 | + 'status' => $statusCode, |
|
385 | + 'title' => $title, |
|
386 | + 'type' => $type, |
|
387 | + 'message' => $message, |
|
388 | + 'result' => $result |
|
389 | 389 | )); |
390 | - } |
|
390 | + } |
|
391 | 391 | |
392 | - /** |
|
393 | - * Remove the specified resource from storage. |
|
394 | - * |
|
395 | - * @param int $id |
|
396 | - * @return Response |
|
397 | - */ |
|
398 | - public function destroy($id) |
|
399 | - { |
|
400 | - EpormasCounter::find($id)->delete(); |
|
401 | - $error = false; |
|
402 | - $statusCode = 200; |
|
403 | - $title = 'Success'; |
|
404 | - $type = 'success'; |
|
405 | - $message = 'Data deleted successfully'; |
|
406 | - return Response::json(array( |
|
392 | + /** |
|
393 | + * Remove the specified resource from storage. |
|
394 | + * |
|
395 | + * @param int $id |
|
396 | + * @return Response |
|
397 | + */ |
|
398 | + public function destroy($id) |
|
399 | + { |
|
400 | + EpormasCounter::find($id)->delete(); |
|
401 | + $error = false; |
|
402 | + $statusCode = 200; |
|
403 | + $title = 'Success'; |
|
404 | + $type = 'success'; |
|
405 | + $message = 'Data deleted successfully'; |
|
406 | + return Response::json(array( |
|
407 | 407 | 'error' => $error, |
408 | 408 | 'status' => $statusCode, |
409 | 409 | 'title' => $title, |
410 | 410 | 'type' => $type, |
411 | 411 | 'message' => $message |
412 | - )); |
|
413 | - } |
|
412 | + )); |
|
413 | + } |
|
414 | 414 | |
415 | 415 | } |
416 | 416 |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return Response |
69 | 69 | */ |
70 | - public function store(Request $request, $version='') |
|
70 | + public function store(Request $request, $version = '') |
|
71 | 71 | { |
72 | 72 | $path = \Request::path(); |
73 | 73 | $explode = explode('/', $path); |
74 | 74 | |
75 | 75 | $from = 'form'; |
76 | - if(in_array('api',$explode)){ |
|
76 | + if (in_array('api', $explode)) { |
|
77 | 77 | $from = 'api'; |
78 | 78 | } |
79 | 79 | |
80 | 80 | $via = $from; |
81 | - if($version != '' && $version != 'store'){ |
|
81 | + if ($version != '' && $version != 'store') { |
|
82 | 82 | $via .= '-'.$version; |
83 | 83 | } |
84 | 84 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $data = EpormasCity::whereNull('deleted_at') |
99 | 99 | ->where('name', $request->name) |
100 | 100 | ->count(); |
101 | - if($data > 0){ |
|
101 | + if ($data > 0) { |
|
102 | 102 | return Response::json(array( |
103 | 103 | 'title' => 'Error', |
104 | 104 | 'type' => 'error', |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param int $id |
148 | 148 | * @return Response |
149 | 149 | */ |
150 | - public function show($version='', $id) |
|
150 | + public function show($version = '', $id) |
|
151 | 151 | { |
152 | 152 | try { |
153 | 153 | $error = false; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param int $id |
230 | 230 | * @return Response |
231 | 231 | */ |
232 | - public function update(Request $request, $version='', $id) |
|
232 | + public function update(Request $request, $version = '', $id) |
|
233 | 233 | { |
234 | 234 | $result = EpormasCity::find($id); |
235 | 235 | |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | )); |
247 | 247 | } |
248 | 248 | |
249 | - if($request->name != $result->name){ |
|
249 | + if ($request->name != $result->name) { |
|
250 | 250 | $data = EpormasCity::whereNull('deleted_at') |
251 | 251 | ->where('name', $request->name) |
252 | 252 | ->count(); |
253 | - if($data > 0){ |
|
253 | + if ($data > 0) { |
|
254 | 254 | return Response::json(array( |
255 | 255 | 'title' => 'Error', |
256 | 256 | 'type' => 'error', |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | $explode = explode('/', $path); |
264 | 264 | |
265 | 265 | $from = 'form'; |
266 | - if(in_array('api',$explode)){ |
|
266 | + if (in_array('api', $explode)) { |
|
267 | 267 | $from = 'api'; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $via = $from; |
271 | - if($version != '' && $version != 'update'){ |
|
271 | + if ($version != '' && $version != 'update') { |
|
272 | 272 | $via .= '-'.$version; |
273 | 273 | } |
274 | 274 |
@@ -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(array( |
|
85 | - 'title' => 'Error', |
|
86 | - 'type' => 'error', |
|
87 | - 'message' => $validator->errors()->all() |
|
88 | - )); |
|
84 | + return Response::json(array( |
|
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(array( |
|
96 | - 'title' => 'Error', |
|
97 | - 'type' => 'error', |
|
98 | - 'message' => 'Data has already been taken.' |
|
99 | - )); |
|
95 | + return Response::json(array( |
|
96 | + 'title' => 'Error', |
|
97 | + 'type' => 'error', |
|
98 | + 'message' => 'Data has already been taken.' |
|
99 | + )); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $error = false; |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | 'name' => $request->name |
109 | 109 | ]); |
110 | 110 | return Response::json(array( |
111 | - 'error' => $error, |
|
112 | - 'status' => $statusCode, |
|
113 | - 'title' => $title, |
|
114 | - 'type' => $type, |
|
115 | - 'message' => $message, |
|
116 | - 'result' => $result |
|
111 | + 'error' => $error, |
|
112 | + 'status' => $statusCode, |
|
113 | + 'title' => $title, |
|
114 | + 'type' => $type, |
|
115 | + 'message' => $message, |
|
116 | + 'result' => $result |
|
117 | 117 | )); |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Display the specified resource. |
|
122 | - * |
|
123 | - * @param int $id |
|
124 | - * @return Response |
|
125 | - */ |
|
126 | - public function show($version='', $id) |
|
127 | - { |
|
120 | + /** |
|
121 | + * Display the specified resource. |
|
122 | + * |
|
123 | + * @param int $id |
|
124 | + * @return Response |
|
125 | + */ |
|
126 | + public function show($version='', $id) |
|
127 | + { |
|
128 | 128 | try { |
129 | 129 | $error = false; |
130 | 130 | $statusCode = 200; |
@@ -141,24 +141,24 @@ discard block |
||
141 | 141 | $result = 'Not Found'; |
142 | 142 | } finally { |
143 | 143 | return Response::json(array( |
144 | - 'error' => $error, |
|
145 | - 'status' => $statusCode, |
|
146 | - 'title' => $title, |
|
147 | - 'type' => $type, |
|
148 | - 'message' => $message, |
|
149 | - 'result' => $result |
|
144 | + 'error' => $error, |
|
145 | + 'status' => $statusCode, |
|
146 | + 'title' => $title, |
|
147 | + 'type' => $type, |
|
148 | + 'message' => $message, |
|
149 | + 'result' => $result |
|
150 | 150 | )); |
151 | 151 | } |
152 | - } |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Show the form for editing the specified resource. |
|
156 | - * |
|
157 | - * @param int $id |
|
158 | - * @return Response |
|
159 | - */ |
|
160 | - public function edit($id) |
|
161 | - { |
|
154 | + /** |
|
155 | + * Show the form for editing the specified resource. |
|
156 | + * |
|
157 | + * @param int $id |
|
158 | + * @return Response |
|
159 | + */ |
|
160 | + public function edit($id) |
|
161 | + { |
|
162 | 162 | try { |
163 | 163 | $error = false; |
164 | 164 | $statusCode = 200; |
@@ -175,24 +175,24 @@ discard block |
||
175 | 175 | $result = 'Not Found'; |
176 | 176 | } finally { |
177 | 177 | return Response::json(array( |
178 | - 'error' => $error, |
|
179 | - 'status' => $statusCode, |
|
180 | - 'title' => $title, |
|
181 | - 'type' => $type, |
|
182 | - 'message' => $message, |
|
183 | - 'result' => $result |
|
178 | + 'error' => $error, |
|
179 | + 'status' => $statusCode, |
|
180 | + 'title' => $title, |
|
181 | + 'type' => $type, |
|
182 | + 'message' => $message, |
|
183 | + 'result' => $result |
|
184 | 184 | )); |
185 | 185 | } |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * Update the specified resource in storage. |
|
190 | - * |
|
191 | - * @param int $id |
|
192 | - * @return Response |
|
193 | - */ |
|
194 | - public function update(Request $request, $version='', $id) |
|
195 | - { |
|
188 | + /** |
|
189 | + * Update the specified resource in storage. |
|
190 | + * |
|
191 | + * @param int $id |
|
192 | + * @return Response |
|
193 | + */ |
|
194 | + public function update(Request $request, $version='', $id) |
|
195 | + { |
|
196 | 196 | $result = EpormasCity::find($id); |
197 | 197 | |
198 | 198 | $rules = [ |
@@ -201,24 +201,24 @@ discard block |
||
201 | 201 | |
202 | 202 | $validator = Validator::make($request->all(), $rules); |
203 | 203 | if ($validator->fails()) { |
204 | - return Response::json(array( |
|
205 | - 'title' => 'Error', |
|
206 | - 'type' => 'error', |
|
207 | - 'message' => $validator->errors()->all() |
|
208 | - )); |
|
204 | + return Response::json(array( |
|
205 | + 'title' => 'Error', |
|
206 | + 'type' => 'error', |
|
207 | + 'message' => $validator->errors()->all() |
|
208 | + )); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | if($request->name != $result->name){ |
212 | - $data = EpormasCity::whereNull('deleted_at') |
|
213 | - ->where('name', $request->name) |
|
214 | - ->count(); |
|
215 | - if($data > 0){ |
|
212 | + $data = EpormasCity::whereNull('deleted_at') |
|
213 | + ->where('name', $request->name) |
|
214 | + ->count(); |
|
215 | + if($data > 0){ |
|
216 | 216 | return Response::json(array( |
217 | 217 | 'title' => 'Error', |
218 | 218 | 'type' => 'error', |
219 | 219 | 'message' => 'Data has already been taken.' |
220 | 220 | )); |
221 | - } |
|
221 | + } |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | $path = \Request::path(); |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | |
227 | 227 | $from = 'form'; |
228 | 228 | if(in_array('api',$explode)){ |
229 | - $from = 'api'; |
|
229 | + $from = 'api'; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | $via = $from; |
233 | 233 | if($version != '' && $version != 'update'){ |
234 | - $via .= '-'.$version; |
|
234 | + $via .= '-'.$version; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | $error = false; |
@@ -243,37 +243,37 @@ discard block |
||
243 | 243 | 'name' => $request->name |
244 | 244 | ]); |
245 | 245 | return Response::json(array( |
246 | - 'error' => $error, |
|
247 | - 'status' => $statusCode, |
|
248 | - 'title' => $title, |
|
249 | - 'type' => $type, |
|
250 | - 'message' => $message, |
|
251 | - 'result' => $result |
|
246 | + 'error' => $error, |
|
247 | + 'status' => $statusCode, |
|
248 | + 'title' => $title, |
|
249 | + 'type' => $type, |
|
250 | + 'message' => $message, |
|
251 | + 'result' => $result |
|
252 | 252 | )); |
253 | - } |
|
253 | + } |
|
254 | 254 | |
255 | - /** |
|
256 | - * Remove the specified resource from storage. |
|
257 | - * |
|
258 | - * @param int $id |
|
259 | - * @return Response |
|
260 | - */ |
|
261 | - public function destroy($id) |
|
262 | - { |
|
263 | - EpormasCity::find($id)->delete(); |
|
264 | - $error = false; |
|
265 | - $statusCode = 200; |
|
266 | - $title = 'Success'; |
|
267 | - $type = 'success'; |
|
268 | - $message = 'Data deleted successfully'; |
|
269 | - return Response::json(array( |
|
255 | + /** |
|
256 | + * Remove the specified resource from storage. |
|
257 | + * |
|
258 | + * @param int $id |
|
259 | + * @return Response |
|
260 | + */ |
|
261 | + public function destroy($id) |
|
262 | + { |
|
263 | + EpormasCity::find($id)->delete(); |
|
264 | + $error = false; |
|
265 | + $statusCode = 200; |
|
266 | + $title = 'Success'; |
|
267 | + $type = 'success'; |
|
268 | + $message = 'Data deleted successfully'; |
|
269 | + return Response::json(array( |
|
270 | 270 | 'error' => $error, |
271 | 271 | 'status' => $statusCode, |
272 | 272 | 'title' => $title, |
273 | 273 | 'type' => $type, |
274 | 274 | 'message' => $message |
275 | - )); |
|
276 | - } |
|
275 | + )); |
|
276 | + } |
|
277 | 277 | |
278 | 278 | } |
279 | 279 |