@@ -35,28 +35,28 @@ |
||
35 | 35 | * @var string |
36 | 36 | */ |
37 | 37 | protected $stubsController = [ |
38 | - 'controllers' => [ |
|
39 | - 'DashboardEpormasController.stub', |
|
40 | - 'EpormasCategoryController.stub', |
|
41 | - 'EpormasCityController.stub', |
|
42 | - 'EpormasCounterController.stub' |
|
43 | - ] |
|
38 | + 'controllers' => [ |
|
39 | + 'DashboardEpormasController.stub', |
|
40 | + 'EpormasCategoryController.stub', |
|
41 | + 'EpormasCityController.stub', |
|
42 | + 'EpormasCounterController.stub' |
|
43 | + ] |
|
44 | 44 | ]; |
45 | 45 | |
46 | 46 | protected $stubsModel = [ |
47 | - 'models' => [ |
|
48 | - 'EpormasCategory.stub', |
|
49 | - 'EpormasCity.stub', |
|
50 | - 'EpormasCounter.stub' |
|
51 | - ] |
|
47 | + 'models' => [ |
|
48 | + 'EpormasCategory.stub', |
|
49 | + 'EpormasCity.stub', |
|
50 | + 'EpormasCounter.stub' |
|
51 | + ] |
|
52 | 52 | ]; |
53 | 53 | |
54 | 54 | protected $stubsSeeds = [ |
55 | - 'seeds' => [ |
|
56 | - 'EpormasCategoryTableSeeder.stub', |
|
57 | - 'EpormasCityTableSeeder.stub', |
|
58 | - 'EpormasCounterTableSeeder.stub' |
|
59 | - ] |
|
55 | + 'seeds' => [ |
|
56 | + 'EpormasCategoryTableSeeder.stub', |
|
57 | + 'EpormasCityTableSeeder.stub', |
|
58 | + 'EpormasCounterTableSeeder.stub' |
|
59 | + ] |
|
60 | 60 | ]; |
61 | 61 | |
62 | 62 | /** |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class CreateEpormasCounterTable extends Migration { |
8 | 8 | |
9 | - public function up() |
|
10 | - { |
|
11 | - Schema::create('epormas_counter', function(Blueprint $table) { |
|
12 | - $table->increments('id'); |
|
13 | - $table->timestamps(); |
|
14 | - $table->softDeletes(); |
|
15 | - $table->integer('tahun')->unsigned()->index(); |
|
16 | - $table->string('bulan', 2)->index(); |
|
17 | - $table->datetime('tanggal')->index(); |
|
18 | - $table->integer('count')->unsigned()->index(); |
|
19 | - $table->string('via')->index(); |
|
20 | - $table->integer('user_id')->unsigned()->index(); |
|
21 | - $table->integer('category_id')->unsigned()->index(); |
|
22 | - $table->integer('city_id')->unsigned()->index(); |
|
23 | - }); |
|
24 | - } |
|
9 | + public function up() |
|
10 | + { |
|
11 | + Schema::create('epormas_counter', function(Blueprint $table) { |
|
12 | + $table->increments('id'); |
|
13 | + $table->timestamps(); |
|
14 | + $table->softDeletes(); |
|
15 | + $table->integer('tahun')->unsigned()->index(); |
|
16 | + $table->string('bulan', 2)->index(); |
|
17 | + $table->datetime('tanggal')->index(); |
|
18 | + $table->integer('count')->unsigned()->index(); |
|
19 | + $table->string('via')->index(); |
|
20 | + $table->integer('user_id')->unsigned()->index(); |
|
21 | + $table->integer('category_id')->unsigned()->index(); |
|
22 | + $table->integer('city_id')->unsigned()->index(); |
|
23 | + }); |
|
24 | + } |
|
25 | 25 | |
26 | - public function down() |
|
27 | - { |
|
28 | - Schema::dropIfExists('epormas_counter'); |
|
29 | - } |
|
26 | + public function down() |
|
27 | + { |
|
28 | + Schema::dropIfExists('epormas_counter'); |
|
29 | + } |
|
30 | 30 | } |
@@ -6,18 +6,18 @@ |
||
6 | 6 | |
7 | 7 | class CreateEpormasCityTable extends Migration { |
8 | 8 | |
9 | - public function up() |
|
10 | - { |
|
11 | - Schema::create('epormas_city', function(Blueprint $table) { |
|
12 | - $table->increments('id'); |
|
13 | - $table->timestamps(); |
|
14 | - $table->softDeletes(); |
|
15 | - $table->string('name', 191)->index(); |
|
16 | - }); |
|
17 | - } |
|
9 | + public function up() |
|
10 | + { |
|
11 | + Schema::create('epormas_city', function(Blueprint $table) { |
|
12 | + $table->increments('id'); |
|
13 | + $table->timestamps(); |
|
14 | + $table->softDeletes(); |
|
15 | + $table->string('name', 191)->index(); |
|
16 | + }); |
|
17 | + } |
|
18 | 18 | |
19 | - public function down() |
|
20 | - { |
|
21 | - Schema::dropIfExists('epormas_city'); |
|
22 | - } |
|
19 | + public function down() |
|
20 | + { |
|
21 | + Schema::dropIfExists('epormas_city'); |
|
22 | + } |
|
23 | 23 | } |
@@ -6,18 +6,18 @@ |
||
6 | 6 | |
7 | 7 | class CreateEpormasCategoryTable extends Migration { |
8 | 8 | |
9 | - public function up() |
|
10 | - { |
|
11 | - Schema::create('epormas_category', function(Blueprint $table) { |
|
12 | - $table->increments('id'); |
|
13 | - $table->timestamps(); |
|
14 | - $table->softDeletes(); |
|
15 | - $table->string('name', 191)->index(); |
|
16 | - }); |
|
17 | - } |
|
9 | + public function up() |
|
10 | + { |
|
11 | + Schema::create('epormas_category', function(Blueprint $table) { |
|
12 | + $table->increments('id'); |
|
13 | + $table->timestamps(); |
|
14 | + $table->softDeletes(); |
|
15 | + $table->string('name', 191)->index(); |
|
16 | + }); |
|
17 | + } |
|
18 | 18 | |
19 | - public function down() |
|
20 | - { |
|
21 | - Schema::dropIfExists('epormas_category'); |
|
22 | - } |
|
19 | + public function down() |
|
20 | + { |
|
21 | + Schema::dropIfExists('epormas_category'); |
|
22 | + } |
|
23 | 23 | } |
@@ -5,34 +5,34 @@ |
||
5 | 5 | |
6 | 6 | class EpormasCityTableSeeder extends Seeder { |
7 | 7 | |
8 | - public function run() |
|
9 | - { |
|
10 | - //DB::table('epormas_city')->delete(); |
|
8 | + public function run() |
|
9 | + { |
|
10 | + //DB::table('epormas_city')->delete(); |
|
11 | 11 | |
12 | - // create_epormas_city_20171201000000 |
|
13 | - EpormasCity::create(array( |
|
14 | - 'name' => 'Kabupaten Pandeglang' |
|
15 | - )); |
|
16 | - EpormasCity::create(array( |
|
17 | - 'name' => 'Kabupaten Lebak' |
|
18 | - )); |
|
19 | - EpormasCity::create(array( |
|
20 | - 'name' => 'Kabupaten Tangerang' |
|
21 | - )); |
|
22 | - EpormasCity::create(array( |
|
23 | - 'name' => 'Kabupaten Serang' |
|
24 | - )); |
|
25 | - EpormasCity::create(array( |
|
26 | - 'name' => 'Kota Tangerang' |
|
27 | - )); |
|
28 | - EpormasCity::create(array( |
|
29 | - 'name' => 'Kota Cilegon' |
|
30 | - )); |
|
31 | - EpormasCity::create(array( |
|
32 | - 'name' => 'Kota Serang' |
|
33 | - )); |
|
34 | - EpormasCity::create(array( |
|
35 | - 'name' => 'Kota Tangerang Selatan' |
|
36 | - )); |
|
37 | - } |
|
12 | + // create_epormas_city_20171201000000 |
|
13 | + EpormasCity::create(array( |
|
14 | + 'name' => 'Kabupaten Pandeglang' |
|
15 | + )); |
|
16 | + EpormasCity::create(array( |
|
17 | + 'name' => 'Kabupaten Lebak' |
|
18 | + )); |
|
19 | + EpormasCity::create(array( |
|
20 | + 'name' => 'Kabupaten Tangerang' |
|
21 | + )); |
|
22 | + EpormasCity::create(array( |
|
23 | + 'name' => 'Kabupaten Serang' |
|
24 | + )); |
|
25 | + EpormasCity::create(array( |
|
26 | + 'name' => 'Kota Tangerang' |
|
27 | + )); |
|
28 | + EpormasCity::create(array( |
|
29 | + 'name' => 'Kota Cilegon' |
|
30 | + )); |
|
31 | + EpormasCity::create(array( |
|
32 | + 'name' => 'Kota Serang' |
|
33 | + )); |
|
34 | + EpormasCity::create(array( |
|
35 | + 'name' => 'Kota Tangerang Selatan' |
|
36 | + )); |
|
37 | + } |
|
38 | 38 | } |
@@ -5,13 +5,13 @@ |
||
5 | 5 | |
6 | 6 | class EpormasCategoryTableSeeder extends Seeder { |
7 | 7 | |
8 | - public function run() |
|
9 | - { |
|
10 | - //DB::table('epormas_category')->delete(); |
|
8 | + public function run() |
|
9 | + { |
|
10 | + //DB::table('epormas_category')->delete(); |
|
11 | 11 | |
12 | - // create_epormas_category_20171201000000 |
|
13 | - EpormasCategory::create(array( |
|
14 | - 'name' => 'Pendidikan' |
|
15 | - )); |
|
16 | - } |
|
12 | + // create_epormas_category_20171201000000 |
|
13 | + EpormasCategory::create(array( |
|
14 | + 'name' => 'Pendidikan' |
|
15 | + )); |
|
16 | + } |
|
17 | 17 | } |
@@ -5,20 +5,20 @@ |
||
5 | 5 | |
6 | 6 | class EpormasCounterTableSeeder extends Seeder { |
7 | 7 | |
8 | - public function run() |
|
9 | - { |
|
10 | - //DB::table('epormas_counter')->delete(); |
|
8 | + public function run() |
|
9 | + { |
|
10 | + //DB::table('epormas_counter')->delete(); |
|
11 | 11 | |
12 | - // create_epormas_counter_20171201000000 |
|
13 | - EpormasCounter::create(array( |
|
14 | - 'tanggal' => '2017-12-01 00:00:12', |
|
15 | - 'count' => 1, |
|
16 | - 'via' => 'form', |
|
17 | - 'user_id' => 1, |
|
18 | - 'tahun' => 2017, |
|
19 | - 'bulan' => 12, |
|
20 | - 'category_id' => 1, |
|
21 | - 'city_id' => 1 |
|
22 | - )); |
|
23 | - } |
|
12 | + // create_epormas_counter_20171201000000 |
|
13 | + EpormasCounter::create(array( |
|
14 | + 'tanggal' => '2017-12-01 00:00:12', |
|
15 | + 'count' => 1, |
|
16 | + 'via' => 'form', |
|
17 | + 'user_id' => 1, |
|
18 | + 'tahun' => 2017, |
|
19 | + 'bulan' => 12, |
|
20 | + 'category_id' => 1, |
|
21 | + 'city_id' => 1 |
|
22 | + )); |
|
23 | + } |
|
24 | 24 | } |
@@ -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 |
@@ -15,32 +15,32 @@ discard block |
||
15 | 15 | { |
16 | 16 | public function epormas() |
17 | 17 | { |
18 | - //Pegawai Epormas |
|
19 | - $grafikepormascounter = DB::table('epormas_counter') |
|
18 | + //Pegawai Epormas |
|
19 | + $grafikepormascounter = DB::table('epormas_counter') |
|
20 | 20 | ->select('tahun','bulan','city_id', DB::raw('SUM(count) as count')) |
21 | 21 | ->whereNull('deleted_at')->groupBy('tahun','bulan','city_id')->orderBy('bulan')->get(); |
22 | - $grafiktahunepormascounter = DB::table('epormas_counter') |
|
22 | + $grafiktahunepormascounter = DB::table('epormas_counter') |
|
23 | 23 | ->select('tahun', DB::raw('SUM(count) as count')) |
24 | 24 | ->whereNull('deleted_at')->groupBy('tahun')->orderBy('tahun')->get(); |
25 | 25 | |
26 | - $namaBulan = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
|
27 | - $namaBulans = array('Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'); |
|
28 | - $city = EpormasCity::all(); |
|
29 | - $category = EpormasCategory::all(); |
|
30 | - $countcity = count($city); |
|
31 | - $countcategory = count($category); |
|
26 | + $namaBulan = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
|
27 | + $namaBulans = array('Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'); |
|
28 | + $city = EpormasCity::all(); |
|
29 | + $category = EpormasCategory::all(); |
|
30 | + $countcity = count($city); |
|
31 | + $countcategory = count($category); |
|
32 | 32 | |
33 | - $countgrafikepormascounter = count($grafikepormascounter); |
|
34 | - $countgrafiktahunepormascounter = count($grafiktahunepormascounter); |
|
35 | - $datagrafikepormascounter = []; |
|
36 | - $datagrafiktahunepormascounter = []; |
|
37 | - $datagrafikcountepormascounter = []; |
|
38 | - $datagrafiktotalepormascounter = []; |
|
39 | - $grafikcountepormascounter = []; |
|
40 | - $grafikbulanepormascounter = []; |
|
41 | - $grafiktotalepormascounter = []; |
|
42 | - $grafikpieepormascounter = []; |
|
43 | - for($q=0; $q<$countgrafiktahunepormascounter; $q++){ |
|
33 | + $countgrafikepormascounter = count($grafikepormascounter); |
|
34 | + $countgrafiktahunepormascounter = count($grafiktahunepormascounter); |
|
35 | + $datagrafikepormascounter = []; |
|
36 | + $datagrafiktahunepormascounter = []; |
|
37 | + $datagrafikcountepormascounter = []; |
|
38 | + $datagrafiktotalepormascounter = []; |
|
39 | + $grafikcountepormascounter = []; |
|
40 | + $grafikbulanepormascounter = []; |
|
41 | + $grafiktotalepormascounter = []; |
|
42 | + $grafikpieepormascounter = []; |
|
43 | + for($q=0; $q<$countgrafiktahunepormascounter; $q++){ |
|
44 | 44 | $tahungrafikepormascounter = $grafiktahunepormascounter[$q]->tahun; |
45 | 45 | $gcountepormascounter = (int)$grafiktahunepormascounter[$q]->count; |
46 | 46 | $totaldataepormascounter = $gcountepormascounter; |
@@ -50,47 +50,47 @@ discard block |
||
50 | 50 | |
51 | 51 | for($kota=1; $kota<=$countcity; $kota++){ |
52 | 52 | for ($index=0; $index<12; $index++) { |
53 | - $grafikcountepormascounter[$q][$kota][$index] = 0; |
|
54 | - $grafikbulanepormascounter[$q][$kota][$index] = 0; |
|
55 | - $grafiktotalepormascounter[$q][$kota][$index] = 0; |
|
56 | - $grafikpieepormascounter[$q][$kota][$index] = ['value'=>0,'name'=>$namaBulan[$index]]; |
|
57 | - $totaldatagrafikepormascounter[$q][$index] = 0; |
|
53 | + $grafikcountepormascounter[$q][$kota][$index] = 0; |
|
54 | + $grafikbulanepormascounter[$q][$kota][$index] = 0; |
|
55 | + $grafiktotalepormascounter[$q][$kota][$index] = 0; |
|
56 | + $grafikpieepormascounter[$q][$kota][$index] = ['value'=>0,'name'=>$namaBulan[$index]]; |
|
57 | + $totaldatagrafikepormascounter[$q][$index] = 0; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | for($r=0; $r<$countgrafikepormascounter; $r++){ |
61 | - $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
|
62 | - $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
|
63 | - $city_id = $grafikepormascounter[$r]->city_id; |
|
64 | - if($bulansepormascounter < 10){ |
|
61 | + $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
|
62 | + $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
|
63 | + $city_id = $grafikepormascounter[$r]->city_id; |
|
64 | + if($bulansepormascounter < 10){ |
|
65 | 65 | $bulanepormascounter = substr($bulansepormascounter,1); |
66 | - }else { |
|
66 | + }else { |
|
67 | 67 | $bulanepormascounter = $bulansepormascounter; |
68 | - } |
|
69 | - if($tahungrafikepormascounter == $tahunsepormascounter){ |
|
70 | - $totaldatagrafikepormascounter[$q][$bulanepormascounter-1] += $grafikepormascounter[$r]->count; |
|
71 | - } |
|
68 | + } |
|
69 | + if($tahungrafikepormascounter == $tahunsepormascounter){ |
|
70 | + $totaldatagrafikepormascounter[$q][$bulanepormascounter-1] += $grafikepormascounter[$r]->count; |
|
71 | + } |
|
72 | 72 | } |
73 | 73 | for($r=0; $r<$countgrafikepormascounter; $r++){ |
74 | - $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
|
75 | - $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
|
76 | - $city_id = $grafikepormascounter[$r]->city_id; |
|
77 | - if($bulansepormascounter < 10){ |
|
74 | + $tahunsepormascounter = $grafikepormascounter[$r]->tahun; |
|
75 | + $bulansepormascounter = $grafikepormascounter[$r]->bulan; |
|
76 | + $city_id = $grafikepormascounter[$r]->city_id; |
|
77 | + if($bulansepormascounter < 10){ |
|
78 | 78 | $bulanepormascounter = substr($bulansepormascounter,1); |
79 | - }else { |
|
79 | + }else { |
|
80 | 80 | $bulanepormascounter = $bulansepormascounter; |
81 | - } |
|
82 | - if($tahungrafikepormascounter == $tahunsepormascounter){ |
|
83 | - $grafikcountepormascounter[$q][$city_id][$bulanepormascounter-1] = (int)$grafikepormascounter[$r]->count; |
|
84 | - $grafikbulanepormascounter[$q][$city_id][$bulanepormascounter-1] = $grafikepormascounter[$r]->bulan; |
|
85 | - $totaldatagrafikepormascounters = $totaldatagrafikepormascounter[$q][$bulanepormascounter-1]; |
|
86 | - $grafiktotalepormascounter[$q][$city_id][$bulanepormascounter-1] = $totaldatagrafikepormascounters; |
|
87 | - $grafikpieepormascounter[$q][$city_id][$bulanepormascounter-1] = ['value'=>$totaldatagrafikepormascounters,'name'=>$namaBulan[$bulanepormascounter-1]]; |
|
88 | - } |
|
81 | + } |
|
82 | + if($tahungrafikepormascounter == $tahunsepormascounter){ |
|
83 | + $grafikcountepormascounter[$q][$city_id][$bulanepormascounter-1] = (int)$grafikepormascounter[$r]->count; |
|
84 | + $grafikbulanepormascounter[$q][$city_id][$bulanepormascounter-1] = $grafikepormascounter[$r]->bulan; |
|
85 | + $totaldatagrafikepormascounters = $totaldatagrafikepormascounter[$q][$bulanepormascounter-1]; |
|
86 | + $grafiktotalepormascounter[$q][$city_id][$bulanepormascounter-1] = $totaldatagrafikepormascounters; |
|
87 | + $grafikpieepormascounter[$q][$city_id][$bulanepormascounter-1] = ['value'=>$totaldatagrafikepormascounters,'name'=>$namaBulan[$bulanepormascounter-1]]; |
|
88 | + } |
|
89 | + } |
|
89 | 90 | } |
90 | - } |
|
91 | - $chartgrafikcountepormascounter = ['chartdata'=>$grafikcountepormascounter]; |
|
92 | - $datagrafikepormascounter = ['count'=>$grafikcountepormascounter, 'bulan'=>$grafikbulanepormascounter, 'namabulan'=>$namaBulan, 'namabulans'=>$namaBulans, 'kategori'=>$category, 'kota'=>$city, 'total'=>$grafiktotalepormascounter, 'datatahun'=>['tahun'=>$datagrafiktahunepormascounter, 'count'=>$datagrafikcountepormascounter, 'totaldata'=>$datagrafiktotalepormascounter], 'datapie'=>$grafikpieepormascounter, 'seriesdata'=>[$chartgrafikcountepormascounter]]; |
|
93 | - //end Pegawai Epormas |
|
91 | + $chartgrafikcountepormascounter = ['chartdata'=>$grafikcountepormascounter]; |
|
92 | + $datagrafikepormascounter = ['count'=>$grafikcountepormascounter, 'bulan'=>$grafikbulanepormascounter, 'namabulan'=>$namaBulan, 'namabulans'=>$namaBulans, 'kategori'=>$category, 'kota'=>$city, 'total'=>$grafiktotalepormascounter, 'datatahun'=>['tahun'=>$datagrafiktahunepormascounter, 'count'=>$datagrafikcountepormascounter, 'totaldata'=>$datagrafiktotalepormascounter], 'datapie'=>$grafikpieepormascounter, 'seriesdata'=>[$chartgrafikcountepormascounter]]; |
|
93 | + //end Pegawai Epormas |
|
94 | 94 | |
95 | 95 | return Response::json(array( |
96 | 96 | //Jumlah Penduduk |