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