@@ -12,98 +12,98 @@ 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 | - 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 | + return Response::json(array( |
|
30 | 30 | 'error' => $error, |
31 | 31 | 'status' => $statusCode, |
32 | 32 | 'title' => $title, |
33 | 33 | 'type' => $type, |
34 | 34 | 'message' => $message, |
35 | 35 | 'result' => $result |
36 | - )); |
|
37 | - } catch (Exception $e) { |
|
38 | - $error = true; |
|
39 | - $statusCode = 404; |
|
40 | - $title = 'Error'; |
|
41 | - $type = 'error'; |
|
42 | - $message = 'Error'; |
|
43 | - $result = 'Not Found'; |
|
44 | - return Response::json(array( |
|
36 | + )); |
|
37 | + } catch (Exception $e) { |
|
38 | + $error = true; |
|
39 | + $statusCode = 404; |
|
40 | + $title = 'Error'; |
|
41 | + $type = 'error'; |
|
42 | + $message = 'Error'; |
|
43 | + $result = 'Not Found'; |
|
44 | + return Response::json(array( |
|
45 | 45 | 'error' => $error, |
46 | 46 | 'status' => $statusCode, |
47 | 47 | 'title' => $title, |
48 | 48 | 'type' => $type, |
49 | 49 | 'message' => $message, |
50 | 50 | 'result' => $result |
51 | - )); |
|
52 | - } |
|
53 | - } |
|
51 | + )); |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Show the form for creating a new resource. |
|
57 | - * |
|
58 | - * @return Response |
|
59 | - */ |
|
60 | - public function create() |
|
61 | - { |
|
55 | + /** |
|
56 | + * Show the form for creating a new resource. |
|
57 | + * |
|
58 | + * @return Response |
|
59 | + */ |
|
60 | + public function create() |
|
61 | + { |
|
62 | 62 | |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Store a newly created resource in storage. |
|
67 | - * |
|
68 | - * @return Response |
|
69 | - */ |
|
70 | - public function store(Request $request, $version='') |
|
71 | - { |
|
65 | + /** |
|
66 | + * Store a newly created resource in storage. |
|
67 | + * |
|
68 | + * @return Response |
|
69 | + */ |
|
70 | + public function store(Request $request, $version='') |
|
71 | + { |
|
72 | 72 | $path = \Request::path(); |
73 | 73 | $explode = explode('/', $path); |
74 | 74 | |
75 | 75 | $from = 'form'; |
76 | 76 | if(in_array('api',$explode)){ |
77 | - $from = 'api'; |
|
77 | + $from = 'api'; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $via = $from; |
81 | 81 | if($version != '' && $version != 'store'){ |
82 | - $via .= '-'.$version; |
|
82 | + $via .= '-'.$version; |
|
83 | 83 | } |
84 | 84 | |
85 | - $rules = [ |
|
85 | + $rules = [ |
|
86 | 86 | 'name' => 'required' |
87 | 87 | ]; |
88 | 88 | |
89 | 89 | $validator = Validator::make($request->all(), $rules); |
90 | 90 | if ($validator->fails()) { |
91 | - return response()->json([ |
|
92 | - 'title' => 'Error', |
|
93 | - 'type' => 'error', |
|
94 | - 'message' => $validator->errors()->all() |
|
95 | - ]); |
|
91 | + return response()->json([ |
|
92 | + 'title' => 'Error', |
|
93 | + 'type' => 'error', |
|
94 | + 'message' => $validator->errors()->all() |
|
95 | + ]); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $data = EpormasCategory::whereNull('deleted_at') |
99 | 99 | ->where('name', $request->name) |
100 | 100 | ->count(); |
101 | 101 | if($data > 0){ |
102 | - return response()->json([ |
|
103 | - 'title' => 'Error', |
|
104 | - 'type' => 'error', |
|
105 | - 'message' => 'Data has already been taken.' |
|
106 | - ]); |
|
102 | + return response()->json([ |
|
103 | + 'title' => 'Error', |
|
104 | + 'type' => 'error', |
|
105 | + 'message' => 'Data has already been taken.' |
|
106 | + ]); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | try { |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | 'name' => $request->name |
117 | 117 | ]); |
118 | 118 | return Response::json(array( |
119 | - 'error' => $error, |
|
120 | - 'status' => $statusCode, |
|
121 | - 'title' => $title, |
|
122 | - 'type' => $type, |
|
123 | - 'message' => $message, |
|
124 | - 'result' => $result |
|
119 | + 'error' => $error, |
|
120 | + 'status' => $statusCode, |
|
121 | + 'title' => $title, |
|
122 | + 'type' => $type, |
|
123 | + 'message' => $message, |
|
124 | + 'result' => $result |
|
125 | 125 | )); |
126 | 126 | } catch (Exception $e) { |
127 | 127 | $error = true; |
@@ -131,24 +131,24 @@ discard block |
||
131 | 131 | $message = 'Error'; |
132 | 132 | $result = 'Not Found'; |
133 | 133 | return Response::json(array( |
134 | - 'error' => $error, |
|
135 | - 'status' => $statusCode, |
|
136 | - 'title' => $title, |
|
137 | - 'type' => $type, |
|
138 | - 'message' => $message, |
|
139 | - 'result' => $result |
|
134 | + 'error' => $error, |
|
135 | + 'status' => $statusCode, |
|
136 | + 'title' => $title, |
|
137 | + 'type' => $type, |
|
138 | + 'message' => $message, |
|
139 | + 'result' => $result |
|
140 | 140 | )); |
141 | 141 | } |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * Display the specified resource. |
|
146 | - * |
|
147 | - * @param int $id |
|
148 | - * @return Response |
|
149 | - */ |
|
150 | - public function show($version='', $id) |
|
151 | - { |
|
144 | + /** |
|
145 | + * Display the specified resource. |
|
146 | + * |
|
147 | + * @param int $id |
|
148 | + * @return Response |
|
149 | + */ |
|
150 | + public function show($version='', $id) |
|
151 | + { |
|
152 | 152 | try { |
153 | 153 | $error = false; |
154 | 154 | $statusCode = 200; |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | $message = 'Success'; |
158 | 158 | $result = EpormasCategory::findOrFail($id); |
159 | 159 | return Response::json(array( |
160 | - 'error' => $error, |
|
161 | - 'status' => $statusCode, |
|
162 | - 'title' => $title, |
|
163 | - 'type' => $type, |
|
164 | - 'message' => $message, |
|
165 | - 'result' => $result |
|
160 | + 'error' => $error, |
|
161 | + 'status' => $statusCode, |
|
162 | + 'title' => $title, |
|
163 | + 'type' => $type, |
|
164 | + 'message' => $message, |
|
165 | + 'result' => $result |
|
166 | 166 | )); |
167 | 167 | } catch (Exception $e) { |
168 | 168 | $error = true; |
@@ -172,24 +172,24 @@ discard block |
||
172 | 172 | $message = 'Error'; |
173 | 173 | $result = 'Not Found'; |
174 | 174 | return Response::json(array( |
175 | - 'error' => $error, |
|
176 | - 'status' => $statusCode, |
|
177 | - 'title' => $title, |
|
178 | - 'type' => $type, |
|
179 | - 'message' => $message, |
|
180 | - 'result' => $result |
|
175 | + 'error' => $error, |
|
176 | + 'status' => $statusCode, |
|
177 | + 'title' => $title, |
|
178 | + 'type' => $type, |
|
179 | + 'message' => $message, |
|
180 | + 'result' => $result |
|
181 | 181 | )); |
182 | 182 | } |
183 | - } |
|
183 | + } |
|
184 | 184 | |
185 | - /** |
|
186 | - * Show the form for editing the specified resource. |
|
187 | - * |
|
188 | - * @param int $id |
|
189 | - * @return Response |
|
190 | - */ |
|
191 | - public function edit($id) |
|
192 | - { |
|
185 | + /** |
|
186 | + * Show the form for editing the specified resource. |
|
187 | + * |
|
188 | + * @param int $id |
|
189 | + * @return Response |
|
190 | + */ |
|
191 | + public function edit($id) |
|
192 | + { |
|
193 | 193 | try { |
194 | 194 | $error = false; |
195 | 195 | $statusCode = 200; |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | $message = 'Success'; |
199 | 199 | $result = EpormasCategory::findOrFail($id); |
200 | 200 | return Response::json(array( |
201 | - 'error' => $error, |
|
202 | - 'status' => $statusCode, |
|
203 | - 'title' => $title, |
|
204 | - 'type' => $type, |
|
205 | - 'message' => $message, |
|
206 | - 'result' => $result |
|
201 | + 'error' => $error, |
|
202 | + 'status' => $statusCode, |
|
203 | + 'title' => $title, |
|
204 | + 'type' => $type, |
|
205 | + 'message' => $message, |
|
206 | + 'result' => $result |
|
207 | 207 | )); |
208 | 208 | } catch (Exception $e) { |
209 | 209 | $error = true; |
@@ -213,24 +213,24 @@ discard block |
||
213 | 213 | $message = 'Error'; |
214 | 214 | $result = 'Not Found'; |
215 | 215 | return Response::json(array( |
216 | - 'error' => $error, |
|
217 | - 'status' => $statusCode, |
|
218 | - 'title' => $title, |
|
219 | - 'type' => $type, |
|
220 | - 'message' => $message, |
|
221 | - 'result' => $result |
|
216 | + 'error' => $error, |
|
217 | + 'status' => $statusCode, |
|
218 | + 'title' => $title, |
|
219 | + 'type' => $type, |
|
220 | + 'message' => $message, |
|
221 | + 'result' => $result |
|
222 | 222 | )); |
223 | 223 | } |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | - /** |
|
227 | - * Update the specified resource in storage. |
|
228 | - * |
|
229 | - * @param int $id |
|
230 | - * @return Response |
|
231 | - */ |
|
232 | - public function update(Request $request, $version='', $id) |
|
233 | - { |
|
226 | + /** |
|
227 | + * Update the specified resource in storage. |
|
228 | + * |
|
229 | + * @param int $id |
|
230 | + * @return Response |
|
231 | + */ |
|
232 | + public function update(Request $request, $version='', $id) |
|
233 | + { |
|
234 | 234 | $result = EpormasCategory::find($id); |
235 | 235 | |
236 | 236 | $rules = [ |
@@ -239,24 +239,24 @@ discard block |
||
239 | 239 | |
240 | 240 | $validator = Validator::make($request->all(), $rules); |
241 | 241 | if ($validator->fails()) { |
242 | - return response()->json([ |
|
243 | - 'title' => 'Error', |
|
244 | - 'type' => 'error', |
|
245 | - 'message' => $validator->errors()->all() |
|
246 | - ]); |
|
242 | + return response()->json([ |
|
243 | + 'title' => 'Error', |
|
244 | + 'type' => 'error', |
|
245 | + 'message' => $validator->errors()->all() |
|
246 | + ]); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | if($request->name != $result->name){ |
250 | - $data = EpormasCategory::whereNull('deleted_at') |
|
251 | - ->where('name', $request->name) |
|
252 | - ->count(); |
|
253 | - if($data > 0){ |
|
250 | + $data = EpormasCategory::whereNull('deleted_at') |
|
251 | + ->where('name', $request->name) |
|
252 | + ->count(); |
|
253 | + if($data > 0){ |
|
254 | 254 | return response()->json([ |
255 | 255 | 'title' => 'Error', |
256 | 256 | 'type' => 'error', |
257 | 257 | 'message' => 'Data has already been taken.' |
258 | 258 | ]); |
259 | - } |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | $path = \Request::path(); |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | |
265 | 265 | $from = 'form'; |
266 | 266 | if(in_array('api',$explode)){ |
267 | - $from = 'api'; |
|
267 | + $from = 'api'; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | $via = $from; |
271 | 271 | if($version != '' && $version != 'update'){ |
272 | - $via .= '-'.$version; |
|
272 | + $via .= '-'.$version; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | try { |
@@ -282,12 +282,12 @@ discard block |
||
282 | 282 | 'name' => $request->name |
283 | 283 | ]); |
284 | 284 | return Response::json(array( |
285 | - 'error' => $error, |
|
286 | - 'status' => $statusCode, |
|
287 | - 'title' => $title, |
|
288 | - 'type' => $type, |
|
289 | - 'message' => $message, |
|
290 | - 'result' => $result |
|
285 | + 'error' => $error, |
|
286 | + 'status' => $statusCode, |
|
287 | + 'title' => $title, |
|
288 | + 'type' => $type, |
|
289 | + 'message' => $message, |
|
290 | + 'result' => $result |
|
291 | 291 | )); |
292 | 292 | } catch (Exception $e) { |
293 | 293 | $error = true; |
@@ -297,53 +297,53 @@ discard block |
||
297 | 297 | $message = 'Error'; |
298 | 298 | $result = 'Not Found'; |
299 | 299 | return Response::json(array( |
300 | - 'error' => $error, |
|
301 | - 'status' => $statusCode, |
|
302 | - 'title' => $title, |
|
303 | - 'type' => $type, |
|
304 | - 'message' => $message, |
|
305 | - 'result' => $result |
|
300 | + 'error' => $error, |
|
301 | + 'status' => $statusCode, |
|
302 | + 'title' => $title, |
|
303 | + 'type' => $type, |
|
304 | + 'message' => $message, |
|
305 | + 'result' => $result |
|
306 | 306 | )); |
307 | 307 | } |
308 | - } |
|
308 | + } |
|
309 | 309 | |
310 | - /** |
|
311 | - * Remove the specified resource from storage. |
|
312 | - * |
|
313 | - * @param int $id |
|
314 | - * @return Response |
|
315 | - */ |
|
316 | - public function destroy($id) |
|
317 | - { |
|
318 | - try { |
|
319 | - EpormasCategory::find($id)->delete(); |
|
320 | - $error = false; |
|
321 | - $statusCode = 200; |
|
322 | - $title = 'Success'; |
|
323 | - $type = 'success'; |
|
324 | - $message = 'Data deleted successfully'; |
|
325 | - return Response::json(array( |
|
310 | + /** |
|
311 | + * Remove the specified resource from storage. |
|
312 | + * |
|
313 | + * @param int $id |
|
314 | + * @return Response |
|
315 | + */ |
|
316 | + public function destroy($id) |
|
317 | + { |
|
318 | + try { |
|
319 | + EpormasCategory::find($id)->delete(); |
|
320 | + $error = false; |
|
321 | + $statusCode = 200; |
|
322 | + $title = 'Success'; |
|
323 | + $type = 'success'; |
|
324 | + $message = 'Data deleted successfully'; |
|
325 | + return Response::json(array( |
|
326 | 326 | 'error' => $error, |
327 | 327 | 'status' => $statusCode, |
328 | 328 | 'title' => $title, |
329 | 329 | 'type' => $type, |
330 | 330 | 'message' => $message |
331 | - )); |
|
332 | - } catch (Exception $e) { |
|
333 | - $error = true; |
|
334 | - $statusCode = 404; |
|
335 | - $title = 'Error'; |
|
336 | - $type = 'error'; |
|
337 | - $message = 'Error'; |
|
338 | - return Response::json(array( |
|
331 | + )); |
|
332 | + } catch (Exception $e) { |
|
333 | + $error = true; |
|
334 | + $statusCode = 404; |
|
335 | + $title = 'Error'; |
|
336 | + $type = 'error'; |
|
337 | + $message = 'Error'; |
|
338 | + return Response::json(array( |
|
339 | 339 | 'error' => $error, |
340 | 340 | 'status' => $statusCode, |
341 | 341 | 'title' => $title, |
342 | 342 | 'type' => $type, |
343 | 343 | 'message' => $message |
344 | - )); |
|
345 | - } |
|
346 | - } |
|
344 | + )); |
|
345 | + } |
|
346 | + } |
|
347 | 347 | |
348 | 348 | } |
349 | 349 |
@@ -12,98 +12,98 @@ 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 | - 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 | + return Response::json(array( |
|
30 | 30 | 'error' => $error, |
31 | 31 | 'status' => $statusCode, |
32 | 32 | 'title' => $title, |
33 | 33 | 'type' => $type, |
34 | 34 | 'message' => $message, |
35 | 35 | 'result' => $result |
36 | - )); |
|
37 | - } catch (Exception $e) { |
|
38 | - $error = true; |
|
39 | - $statusCode = 404; |
|
40 | - $title = 'Error'; |
|
41 | - $type = 'error'; |
|
42 | - $message = 'Error'; |
|
43 | - $result = 'Not Found'; |
|
44 | - return Response::json(array( |
|
36 | + )); |
|
37 | + } catch (Exception $e) { |
|
38 | + $error = true; |
|
39 | + $statusCode = 404; |
|
40 | + $title = 'Error'; |
|
41 | + $type = 'error'; |
|
42 | + $message = 'Error'; |
|
43 | + $result = 'Not Found'; |
|
44 | + return Response::json(array( |
|
45 | 45 | 'error' => $error, |
46 | 46 | 'status' => $statusCode, |
47 | 47 | 'title' => $title, |
48 | 48 | 'type' => $type, |
49 | 49 | 'message' => $message, |
50 | 50 | 'result' => $result |
51 | - )); |
|
52 | - } |
|
53 | - } |
|
51 | + )); |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Show the form for creating a new resource. |
|
57 | - * |
|
58 | - * @return Response |
|
59 | - */ |
|
60 | - public function create() |
|
61 | - { |
|
55 | + /** |
|
56 | + * Show the form for creating a new resource. |
|
57 | + * |
|
58 | + * @return Response |
|
59 | + */ |
|
60 | + public function create() |
|
61 | + { |
|
62 | 62 | |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Store a newly created resource in storage. |
|
67 | - * |
|
68 | - * @return Response |
|
69 | - */ |
|
70 | - public function store(Request $request, $version='') |
|
71 | - { |
|
65 | + /** |
|
66 | + * Store a newly created resource in storage. |
|
67 | + * |
|
68 | + * @return Response |
|
69 | + */ |
|
70 | + public function store(Request $request, $version='') |
|
71 | + { |
|
72 | 72 | $path = \Request::path(); |
73 | 73 | $explode = explode('/', $path); |
74 | 74 | |
75 | 75 | $from = 'form'; |
76 | 76 | if(in_array('api',$explode)){ |
77 | - $from = 'api'; |
|
77 | + $from = 'api'; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $via = $from; |
81 | 81 | if($version != '' && $version != 'store'){ |
82 | - $via .= '-'.$version; |
|
82 | + $via .= '-'.$version; |
|
83 | 83 | } |
84 | 84 | |
85 | - $rules = [ |
|
85 | + $rules = [ |
|
86 | 86 | 'name' => 'required' |
87 | 87 | ]; |
88 | 88 | |
89 | 89 | $validator = Validator::make($request->all(), $rules); |
90 | 90 | if ($validator->fails()) { |
91 | - return response()->json([ |
|
92 | - 'title' => 'Error', |
|
93 | - 'type' => 'error', |
|
94 | - 'message' => $validator->errors()->all() |
|
95 | - ]); |
|
91 | + return response()->json([ |
|
92 | + 'title' => 'Error', |
|
93 | + 'type' => 'error', |
|
94 | + 'message' => $validator->errors()->all() |
|
95 | + ]); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $data = EpormasCity::whereNull('deleted_at') |
99 | 99 | ->where('name', $request->name) |
100 | 100 | ->count(); |
101 | 101 | if($data > 0){ |
102 | - return response()->json([ |
|
103 | - 'title' => 'Error', |
|
104 | - 'type' => 'error', |
|
105 | - 'message' => 'Data has already been taken.' |
|
106 | - ]); |
|
102 | + return response()->json([ |
|
103 | + 'title' => 'Error', |
|
104 | + 'type' => 'error', |
|
105 | + 'message' => 'Data has already been taken.' |
|
106 | + ]); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | try { |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | 'name' => $request->name |
117 | 117 | ]); |
118 | 118 | return Response::json(array( |
119 | - 'error' => $error, |
|
120 | - 'status' => $statusCode, |
|
121 | - 'title' => $title, |
|
122 | - 'type' => $type, |
|
123 | - 'message' => $message, |
|
124 | - 'result' => $result |
|
119 | + 'error' => $error, |
|
120 | + 'status' => $statusCode, |
|
121 | + 'title' => $title, |
|
122 | + 'type' => $type, |
|
123 | + 'message' => $message, |
|
124 | + 'result' => $result |
|
125 | 125 | )); |
126 | 126 | } catch (Exception $e) { |
127 | 127 | $error = true; |
@@ -131,24 +131,24 @@ discard block |
||
131 | 131 | $message = 'Error'; |
132 | 132 | $result = 'Not Found'; |
133 | 133 | return Response::json(array( |
134 | - 'error' => $error, |
|
135 | - 'status' => $statusCode, |
|
136 | - 'title' => $title, |
|
137 | - 'type' => $type, |
|
138 | - 'message' => $message, |
|
139 | - 'result' => $result |
|
134 | + 'error' => $error, |
|
135 | + 'status' => $statusCode, |
|
136 | + 'title' => $title, |
|
137 | + 'type' => $type, |
|
138 | + 'message' => $message, |
|
139 | + 'result' => $result |
|
140 | 140 | )); |
141 | 141 | } |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * Display the specified resource. |
|
146 | - * |
|
147 | - * @param int $id |
|
148 | - * @return Response |
|
149 | - */ |
|
150 | - public function show($version='', $id) |
|
151 | - { |
|
144 | + /** |
|
145 | + * Display the specified resource. |
|
146 | + * |
|
147 | + * @param int $id |
|
148 | + * @return Response |
|
149 | + */ |
|
150 | + public function show($version='', $id) |
|
151 | + { |
|
152 | 152 | try { |
153 | 153 | $error = false; |
154 | 154 | $statusCode = 200; |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | $message = 'Success'; |
158 | 158 | $result = EpormasCity::findOrFail($id); |
159 | 159 | return Response::json(array( |
160 | - 'error' => $error, |
|
161 | - 'status' => $statusCode, |
|
162 | - 'title' => $title, |
|
163 | - 'type' => $type, |
|
164 | - 'message' => $message, |
|
165 | - 'result' => $result |
|
160 | + 'error' => $error, |
|
161 | + 'status' => $statusCode, |
|
162 | + 'title' => $title, |
|
163 | + 'type' => $type, |
|
164 | + 'message' => $message, |
|
165 | + 'result' => $result |
|
166 | 166 | )); |
167 | 167 | } catch (Exception $e) { |
168 | 168 | $error = true; |
@@ -172,24 +172,24 @@ discard block |
||
172 | 172 | $message = 'Error'; |
173 | 173 | $result = 'Not Found'; |
174 | 174 | return Response::json(array( |
175 | - 'error' => $error, |
|
176 | - 'status' => $statusCode, |
|
177 | - 'title' => $title, |
|
178 | - 'type' => $type, |
|
179 | - 'message' => $message, |
|
180 | - 'result' => $result |
|
175 | + 'error' => $error, |
|
176 | + 'status' => $statusCode, |
|
177 | + 'title' => $title, |
|
178 | + 'type' => $type, |
|
179 | + 'message' => $message, |
|
180 | + 'result' => $result |
|
181 | 181 | )); |
182 | 182 | } |
183 | - } |
|
183 | + } |
|
184 | 184 | |
185 | - /** |
|
186 | - * Show the form for editing the specified resource. |
|
187 | - * |
|
188 | - * @param int $id |
|
189 | - * @return Response |
|
190 | - */ |
|
191 | - public function edit($id) |
|
192 | - { |
|
185 | + /** |
|
186 | + * Show the form for editing the specified resource. |
|
187 | + * |
|
188 | + * @param int $id |
|
189 | + * @return Response |
|
190 | + */ |
|
191 | + public function edit($id) |
|
192 | + { |
|
193 | 193 | try { |
194 | 194 | $error = false; |
195 | 195 | $statusCode = 200; |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | $message = 'Success'; |
199 | 199 | $result = EpormasCity::findOrFail($id); |
200 | 200 | return Response::json(array( |
201 | - 'error' => $error, |
|
202 | - 'status' => $statusCode, |
|
203 | - 'title' => $title, |
|
204 | - 'type' => $type, |
|
205 | - 'message' => $message, |
|
206 | - 'result' => $result |
|
201 | + 'error' => $error, |
|
202 | + 'status' => $statusCode, |
|
203 | + 'title' => $title, |
|
204 | + 'type' => $type, |
|
205 | + 'message' => $message, |
|
206 | + 'result' => $result |
|
207 | 207 | )); |
208 | 208 | } catch (Exception $e) { |
209 | 209 | $error = true; |
@@ -213,24 +213,24 @@ discard block |
||
213 | 213 | $message = 'Error'; |
214 | 214 | $result = 'Not Found'; |
215 | 215 | return Response::json(array( |
216 | - 'error' => $error, |
|
217 | - 'status' => $statusCode, |
|
218 | - 'title' => $title, |
|
219 | - 'type' => $type, |
|
220 | - 'message' => $message, |
|
221 | - 'result' => $result |
|
216 | + 'error' => $error, |
|
217 | + 'status' => $statusCode, |
|
218 | + 'title' => $title, |
|
219 | + 'type' => $type, |
|
220 | + 'message' => $message, |
|
221 | + 'result' => $result |
|
222 | 222 | )); |
223 | 223 | } |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | - /** |
|
227 | - * Update the specified resource in storage. |
|
228 | - * |
|
229 | - * @param int $id |
|
230 | - * @return Response |
|
231 | - */ |
|
232 | - public function update(Request $request, $version='', $id) |
|
233 | - { |
|
226 | + /** |
|
227 | + * Update the specified resource in storage. |
|
228 | + * |
|
229 | + * @param int $id |
|
230 | + * @return Response |
|
231 | + */ |
|
232 | + public function update(Request $request, $version='', $id) |
|
233 | + { |
|
234 | 234 | $result = EpormasCity::find($id); |
235 | 235 | |
236 | 236 | $rules = [ |
@@ -239,24 +239,24 @@ discard block |
||
239 | 239 | |
240 | 240 | $validator = Validator::make($request->all(), $rules); |
241 | 241 | if ($validator->fails()) { |
242 | - return response()->json([ |
|
243 | - 'title' => 'Error', |
|
244 | - 'type' => 'error', |
|
245 | - 'message' => $validator->errors()->all() |
|
246 | - ]); |
|
242 | + return response()->json([ |
|
243 | + 'title' => 'Error', |
|
244 | + 'type' => 'error', |
|
245 | + 'message' => $validator->errors()->all() |
|
246 | + ]); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | if($request->name != $result->name){ |
250 | - $data = EpormasCity::whereNull('deleted_at') |
|
251 | - ->where('name', $request->name) |
|
252 | - ->count(); |
|
253 | - if($data > 0){ |
|
250 | + $data = EpormasCity::whereNull('deleted_at') |
|
251 | + ->where('name', $request->name) |
|
252 | + ->count(); |
|
253 | + if($data > 0){ |
|
254 | 254 | return response()->json([ |
255 | 255 | 'title' => 'Error', |
256 | 256 | 'type' => 'error', |
257 | 257 | 'message' => 'Data has already been taken.' |
258 | 258 | ]); |
259 | - } |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | $path = \Request::path(); |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | |
265 | 265 | $from = 'form'; |
266 | 266 | if(in_array('api',$explode)){ |
267 | - $from = 'api'; |
|
267 | + $from = 'api'; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | $via = $from; |
271 | 271 | if($version != '' && $version != 'update'){ |
272 | - $via .= '-'.$version; |
|
272 | + $via .= '-'.$version; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | try { |
@@ -282,12 +282,12 @@ discard block |
||
282 | 282 | 'name' => $request->name |
283 | 283 | ]); |
284 | 284 | return Response::json(array( |
285 | - 'error' => $error, |
|
286 | - 'status' => $statusCode, |
|
287 | - 'title' => $title, |
|
288 | - 'type' => $type, |
|
289 | - 'message' => $message, |
|
290 | - 'result' => $result |
|
285 | + 'error' => $error, |
|
286 | + 'status' => $statusCode, |
|
287 | + 'title' => $title, |
|
288 | + 'type' => $type, |
|
289 | + 'message' => $message, |
|
290 | + 'result' => $result |
|
291 | 291 | )); |
292 | 292 | } catch (Exception $e) { |
293 | 293 | $error = true; |
@@ -297,53 +297,53 @@ discard block |
||
297 | 297 | $message = 'Error'; |
298 | 298 | $result = 'Not Found'; |
299 | 299 | return Response::json(array( |
300 | - 'error' => $error, |
|
301 | - 'status' => $statusCode, |
|
302 | - 'title' => $title, |
|
303 | - 'type' => $type, |
|
304 | - 'message' => $message, |
|
305 | - 'result' => $result |
|
300 | + 'error' => $error, |
|
301 | + 'status' => $statusCode, |
|
302 | + 'title' => $title, |
|
303 | + 'type' => $type, |
|
304 | + 'message' => $message, |
|
305 | + 'result' => $result |
|
306 | 306 | )); |
307 | 307 | } |
308 | - } |
|
308 | + } |
|
309 | 309 | |
310 | - /** |
|
311 | - * Remove the specified resource from storage. |
|
312 | - * |
|
313 | - * @param int $id |
|
314 | - * @return Response |
|
315 | - */ |
|
316 | - public function destroy($id) |
|
317 | - { |
|
318 | - try { |
|
319 | - EpormasCity::find($id)->delete(); |
|
320 | - $error = false; |
|
321 | - $statusCode = 200; |
|
322 | - $title = 'Success'; |
|
323 | - $type = 'success'; |
|
324 | - $message = 'Data deleted successfully'; |
|
325 | - return Response::json(array( |
|
310 | + /** |
|
311 | + * Remove the specified resource from storage. |
|
312 | + * |
|
313 | + * @param int $id |
|
314 | + * @return Response |
|
315 | + */ |
|
316 | + public function destroy($id) |
|
317 | + { |
|
318 | + try { |
|
319 | + EpormasCity::find($id)->delete(); |
|
320 | + $error = false; |
|
321 | + $statusCode = 200; |
|
322 | + $title = 'Success'; |
|
323 | + $type = 'success'; |
|
324 | + $message = 'Data deleted successfully'; |
|
325 | + return Response::json(array( |
|
326 | 326 | 'error' => $error, |
327 | 327 | 'status' => $statusCode, |
328 | 328 | 'title' => $title, |
329 | 329 | 'type' => $type, |
330 | 330 | 'message' => $message |
331 | - )); |
|
332 | - } catch (Exception $e) { |
|
333 | - $error = true; |
|
334 | - $statusCode = 404; |
|
335 | - $title = 'Error'; |
|
336 | - $type = 'error'; |
|
337 | - $message = 'Error'; |
|
338 | - return Response::json(array( |
|
331 | + )); |
|
332 | + } catch (Exception $e) { |
|
333 | + $error = true; |
|
334 | + $statusCode = 404; |
|
335 | + $title = 'Error'; |
|
336 | + $type = 'error'; |
|
337 | + $message = 'Error'; |
|
338 | + return Response::json(array( |
|
339 | 339 | 'error' => $error, |
340 | 340 | 'status' => $statusCode, |
341 | 341 | 'title' => $title, |
342 | 342 | 'type' => $type, |
343 | 343 | 'message' => $message |
344 | - )); |
|
345 | - } |
|
346 | - } |
|
344 | + )); |
|
345 | + } |
|
346 | + } |
|
347 | 347 | |
348 | 348 | } |
349 | 349 |