@@ -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 |
@@ -12,91 +12,91 @@ discard block |
||
12 | 12 | class EpormasCategoryController extends Controller |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Display a listing of the resource. |
|
17 | - * |
|
18 | - * @return Response |
|
19 | - */ |
|
20 | - public function index() |
|
21 | - { |
|
22 | - try { |
|
23 | - $error = false; |
|
24 | - $statusCode = 200; |
|
25 | - $title = 'Success'; |
|
26 | - $type = 'success'; |
|
27 | - $message = 'Success'; |
|
28 | - $result = EpormasCategory::all(); |
|
29 | - } catch (Exception $e) { |
|
30 | - $error = true; |
|
31 | - $statusCode = 404; |
|
32 | - $title = 'Error'; |
|
33 | - $type = 'error'; |
|
34 | - $message = 'Error'; |
|
35 | - $result = 'Not Found'; |
|
36 | - } finally { |
|
37 | - return Response::json(array( |
|
15 | + /** |
|
16 | + * Display a listing of the resource. |
|
17 | + * |
|
18 | + * @return Response |
|
19 | + */ |
|
20 | + public function index() |
|
21 | + { |
|
22 | + try { |
|
23 | + $error = false; |
|
24 | + $statusCode = 200; |
|
25 | + $title = 'Success'; |
|
26 | + $type = 'success'; |
|
27 | + $message = 'Success'; |
|
28 | + $result = EpormasCategory::all(); |
|
29 | + } catch (Exception $e) { |
|
30 | + $error = true; |
|
31 | + $statusCode = 404; |
|
32 | + $title = 'Error'; |
|
33 | + $type = 'error'; |
|
34 | + $message = 'Error'; |
|
35 | + $result = 'Not Found'; |
|
36 | + } finally { |
|
37 | + return Response::json(array( |
|
38 | 38 | 'error' => $error, |
39 | 39 | 'status' => $statusCode, |
40 | 40 | 'title' => $title, |
41 | 41 | 'type' => $type, |
42 | 42 | 'message' => $message, |
43 | 43 | 'result' => $result |
44 | - )); |
|
45 | - } |
|
46 | - } |
|
44 | + )); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Show the form for creating a new resource. |
|
50 | - * |
|
51 | - * @return Response |
|
52 | - */ |
|
53 | - public function create() |
|
54 | - { |
|
48 | + /** |
|
49 | + * Show the form for creating a new resource. |
|
50 | + * |
|
51 | + * @return Response |
|
52 | + */ |
|
53 | + public function create() |
|
54 | + { |
|
55 | 55 | |
56 | - } |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Store a newly created resource in storage. |
|
60 | - * |
|
61 | - * @return Response |
|
62 | - */ |
|
63 | - public function store(Request $request, $version='') |
|
64 | - { |
|
58 | + /** |
|
59 | + * Store a newly created resource in storage. |
|
60 | + * |
|
61 | + * @return Response |
|
62 | + */ |
|
63 | + public function store(Request $request, $version='') |
|
64 | + { |
|
65 | 65 | $path = \Request::path(); |
66 | 66 | $explode = explode('/', $path); |
67 | 67 | |
68 | 68 | $from = 'form'; |
69 | 69 | if(in_array('api',$explode)){ |
70 | - $from = 'api'; |
|
70 | + $from = 'api'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $via = $from; |
74 | 74 | if($version != '' && $version != 'store'){ |
75 | - $via .= '-'.$version; |
|
75 | + $via .= '-'.$version; |
|
76 | 76 | } |
77 | 77 | |
78 | - $rules = [ |
|
78 | + $rules = [ |
|
79 | 79 | 'name' => 'required' |
80 | 80 | ]; |
81 | 81 | |
82 | 82 | $validator = Validator::make($request->all(), $rules); |
83 | 83 | if ($validator->fails()) { |
84 | - return Response::json(array( |
|
85 | - 'title' => 'Error', |
|
86 | - 'type' => 'error', |
|
87 | - 'message' => $validator->errors()->all() |
|
88 | - )); |
|
84 | + return Response::json(array( |
|
85 | + 'title' => 'Error', |
|
86 | + 'type' => 'error', |
|
87 | + 'message' => $validator->errors()->all() |
|
88 | + )); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $data = EpormasCategory::whereNull('deleted_at') |
92 | 92 | ->where('name', $request->name) |
93 | 93 | ->count(); |
94 | 94 | if($data > 0){ |
95 | - return Response::json(array( |
|
96 | - 'title' => 'Error', |
|
97 | - 'type' => 'error', |
|
98 | - 'message' => 'Data has already been taken.' |
|
99 | - )); |
|
95 | + return Response::json(array( |
|
96 | + 'title' => 'Error', |
|
97 | + 'type' => 'error', |
|
98 | + 'message' => 'Data has already been taken.' |
|
99 | + )); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $error = false; |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | 'name' => $request->name |
109 | 109 | ]); |
110 | 110 | return Response::json(array( |
111 | - 'error' => $error, |
|
112 | - 'status' => $statusCode, |
|
113 | - 'title' => $title, |
|
114 | - 'type' => $type, |
|
115 | - 'message' => $message, |
|
116 | - 'result' => $result |
|
111 | + 'error' => $error, |
|
112 | + 'status' => $statusCode, |
|
113 | + 'title' => $title, |
|
114 | + 'type' => $type, |
|
115 | + 'message' => $message, |
|
116 | + 'result' => $result |
|
117 | 117 | )); |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Display the specified resource. |
|
122 | - * |
|
123 | - * @param int $id |
|
124 | - * @return Response |
|
125 | - */ |
|
126 | - public function show($version='', $id) |
|
127 | - { |
|
120 | + /** |
|
121 | + * Display the specified resource. |
|
122 | + * |
|
123 | + * @param int $id |
|
124 | + * @return Response |
|
125 | + */ |
|
126 | + public function show($version='', $id) |
|
127 | + { |
|
128 | 128 | try { |
129 | 129 | $error = false; |
130 | 130 | $statusCode = 200; |
@@ -141,24 +141,24 @@ discard block |
||
141 | 141 | $result = 'Not Found'; |
142 | 142 | } finally { |
143 | 143 | return Response::json(array( |
144 | - 'error' => $error, |
|
145 | - 'status' => $statusCode, |
|
146 | - 'title' => $title, |
|
147 | - 'type' => $type, |
|
148 | - 'message' => $message, |
|
149 | - 'result' => $result |
|
144 | + 'error' => $error, |
|
145 | + 'status' => $statusCode, |
|
146 | + 'title' => $title, |
|
147 | + 'type' => $type, |
|
148 | + 'message' => $message, |
|
149 | + 'result' => $result |
|
150 | 150 | )); |
151 | 151 | } |
152 | - } |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
155 | - * Show the form for editing the specified resource. |
|
156 | - * |
|
157 | - * @param int $id |
|
158 | - * @return Response |
|
159 | - */ |
|
160 | - public function edit($id) |
|
161 | - { |
|
154 | + /** |
|
155 | + * Show the form for editing the specified resource. |
|
156 | + * |
|
157 | + * @param int $id |
|
158 | + * @return Response |
|
159 | + */ |
|
160 | + public function edit($id) |
|
161 | + { |
|
162 | 162 | try { |
163 | 163 | $error = false; |
164 | 164 | $statusCode = 200; |
@@ -175,24 +175,24 @@ discard block |
||
175 | 175 | $result = 'Not Found'; |
176 | 176 | } finally { |
177 | 177 | return Response::json(array( |
178 | - 'error' => $error, |
|
179 | - 'status' => $statusCode, |
|
180 | - 'title' => $title, |
|
181 | - 'type' => $type, |
|
182 | - 'message' => $message, |
|
183 | - 'result' => $result |
|
178 | + 'error' => $error, |
|
179 | + 'status' => $statusCode, |
|
180 | + 'title' => $title, |
|
181 | + 'type' => $type, |
|
182 | + 'message' => $message, |
|
183 | + 'result' => $result |
|
184 | 184 | )); |
185 | 185 | } |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * Update the specified resource in storage. |
|
190 | - * |
|
191 | - * @param int $id |
|
192 | - * @return Response |
|
193 | - */ |
|
194 | - public function update(Request $request, $version='', $id) |
|
195 | - { |
|
188 | + /** |
|
189 | + * Update the specified resource in storage. |
|
190 | + * |
|
191 | + * @param int $id |
|
192 | + * @return Response |
|
193 | + */ |
|
194 | + public function update(Request $request, $version='', $id) |
|
195 | + { |
|
196 | 196 | $result = EpormasCategory::find($id); |
197 | 197 | |
198 | 198 | $rules = [ |
@@ -201,23 +201,23 @@ discard block |
||
201 | 201 | |
202 | 202 | $validator = Validator::make($request->all(), $rules); |
203 | 203 | if ($validator->fails()) { |
204 | - return Response::json(array( |
|
205 | - 'type' => 'error', |
|
206 | - 'message' => $validator->errors()->all() |
|
207 | - )); |
|
204 | + return Response::json(array( |
|
205 | + 'type' => 'error', |
|
206 | + 'message' => $validator->errors()->all() |
|
207 | + )); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | if($request->name != $result->name){ |
211 | - $data = EpormasCategory::whereNull('deleted_at') |
|
212 | - ->where('name', $request->name) |
|
213 | - ->count(); |
|
214 | - if($data > 0){ |
|
211 | + $data = EpormasCategory::whereNull('deleted_at') |
|
212 | + ->where('name', $request->name) |
|
213 | + ->count(); |
|
214 | + if($data > 0){ |
|
215 | 215 | return Response::json(array( |
216 | 216 | 'title' => 'Error', |
217 | 217 | 'type' => 'error', |
218 | 218 | 'message' => 'Data has already been taken.' |
219 | 219 | )); |
220 | - } |
|
220 | + } |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | $path = \Request::path(); |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | |
226 | 226 | $from = 'form'; |
227 | 227 | if(in_array('api',$explode)){ |
228 | - $from = 'api'; |
|
228 | + $from = 'api'; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $via = $from; |
232 | 232 | if($version != '' && $version != 'update'){ |
233 | - $via .= '-'.$version; |
|
233 | + $via .= '-'.$version; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | $error = false; |
@@ -242,37 +242,37 @@ discard block |
||
242 | 242 | 'name' => $request->name |
243 | 243 | ]); |
244 | 244 | return Response::json(array( |
245 | - 'error' => $error, |
|
246 | - 'status' => $statusCode, |
|
247 | - 'title' => $title, |
|
248 | - 'type' => $type, |
|
249 | - 'message' => $message, |
|
250 | - 'result' => $result |
|
245 | + 'error' => $error, |
|
246 | + 'status' => $statusCode, |
|
247 | + 'title' => $title, |
|
248 | + 'type' => $type, |
|
249 | + 'message' => $message, |
|
250 | + 'result' => $result |
|
251 | 251 | )); |
252 | - } |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * Remove the specified resource from storage. |
|
256 | - * |
|
257 | - * @param int $id |
|
258 | - * @return Response |
|
259 | - */ |
|
260 | - public function destroy($id) |
|
261 | - { |
|
262 | - EpormasCategory::find($id)->delete(); |
|
263 | - $error = false; |
|
264 | - $statusCode = 200; |
|
265 | - $title = 'Success'; |
|
266 | - $type = 'success'; |
|
267 | - $message = 'Data deleted successfully'; |
|
268 | - return Response::json(array( |
|
254 | + /** |
|
255 | + * Remove the specified resource from storage. |
|
256 | + * |
|
257 | + * @param int $id |
|
258 | + * @return Response |
|
259 | + */ |
|
260 | + public function destroy($id) |
|
261 | + { |
|
262 | + EpormasCategory::find($id)->delete(); |
|
263 | + $error = false; |
|
264 | + $statusCode = 200; |
|
265 | + $title = 'Success'; |
|
266 | + $type = 'success'; |
|
267 | + $message = 'Data deleted successfully'; |
|
268 | + return Response::json(array( |
|
269 | 269 | 'error' => $error, |
270 | 270 | 'status' => $statusCode, |
271 | 271 | 'title' => $title, |
272 | 272 | 'type' => $type, |
273 | 273 | 'message' => $message |
274 | - )); |
|
275 | - } |
|
274 | + )); |
|
275 | + } |
|
276 | 276 | |
277 | 277 | } |
278 | 278 |