@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('dashboardApel')) { |
|
3 | +if (!function_exists('dashboardApel')) { |
|
4 | 4 | function dashboardApel() |
5 | 5 | { |
6 | 6 | return 'Welcome to function dashboardApel() for Bantenprov\DashboardApel package'; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | $this->regency = $regency; |
34 | 34 | $this->province = $province; |
35 | - $this->dashboard_apel = $dashboard_apel; |
|
35 | + $this->dashboard_apel = $dashboard_apel; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function index(Request $request) |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function store(Request $request) |
70 | 70 | { |
71 | 71 | |
72 | - $validator = Validator::make($request->all(),[ |
|
72 | + $validator = Validator::make($request->all(), [ |
|
73 | 73 | 'negara' => 'required', |
74 | 74 | 'province_id' => 'required', |
75 | 75 | 'regency_id' => 'required', |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | 'data' => 'required|integer', |
79 | 79 | ]); |
80 | 80 | |
81 | - if($validator->fails()) |
|
81 | + if ($validator->fails()) |
|
82 | 82 | { |
83 | 83 | return response()->json([ |
84 | 84 | 'title' => 'error', |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | ]); |
89 | 89 | } |
90 | 90 | |
91 | - $check = $this->dashboard-apel->where('regency_id',$request->regency_id)->where('tahun',$request->tahun)->count(); |
|
91 | + $check = $this->dashboard-apel->where('regency_id', $request->regency_id)->where('tahun', $request->tahun)->count(); |
|
92 | 92 | |
93 | - if($check > 0) |
|
93 | + if ($check > 0) |
|
94 | 94 | { |
95 | 95 | return response()->json([ |
96 | 96 | 'title' => 'error', |
@@ -98,14 +98,14 @@ discard block |
||
98 | 98 | 'type' => 'failed', |
99 | 99 | ]); |
100 | 100 | |
101 | - }else{ |
|
101 | + }else { |
|
102 | 102 | $data = $this->dashboard-apel->create($request->all()); |
103 | 103 | |
104 | 104 | return response()->json([ |
105 | 105 | 'type' => 'success', |
106 | 106 | 'title' => 'success', |
107 | 107 | 'id' => $data->id, |
108 | - 'message' => 'PDRB '. $this->regency->find($request->regency_id)->name .' tahun '. $request->tahun .' successfully created', |
|
108 | + 'message' => 'PDRB '.$this->regency->find($request->regency_id)->name.' tahun '.$request->tahun.' successfully created', |
|
109 | 109 | ]); |
110 | 110 | } |
111 | 111 |
@@ -98,7 +98,7 @@ |
||
98 | 98 | 'type' => 'failed', |
99 | 99 | ]); |
100 | 100 | |
101 | - }else{ |
|
101 | + } else{ |
|
102 | 102 | $data = $this->dashboard-apel->create($request->all()); |
103 | 103 | |
104 | 104 | return response()->json([ |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | public function getProvince() |
20 | 20 | { |
21 | - return $this->hasOne('Bantenprov\DashboardApel\Models\Bantenprov\DashboardApel\Province','id','province_id'); |
|
21 | + return $this->hasOne('Bantenprov\DashboardApel\Models\Bantenprov\DashboardApel\Province', 'id', 'province_id'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -18,12 +18,12 @@ |
||
18 | 18 | |
19 | 19 | public function getProvince() |
20 | 20 | { |
21 | - return $this->hasOne('Bantenprov\DashboardApel\Models\Bantenprov\DashboardApel\Province','id','province_id'); |
|
21 | + return $this->hasOne('Bantenprov\DashboardApel\Models\Bantenprov\DashboardApel\Province', 'id', 'province_id'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function getRegency() |
25 | 25 | { |
26 | - return $this->hasOne('Bantenprov\DashboardApel\Models\Bantenprov\DashboardApel\Regency','id','regency_id'); |
|
26 | + return $this->hasOne('Bantenprov\DashboardApel\Models\Bantenprov\DashboardApel\Regency', 'id', 'regency_id'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | } |
@@ -5,19 +5,19 @@ |
||
5 | 5 | |
6 | 6 | class CreateRegenciesTable extends Migration { |
7 | 7 | |
8 | - public function up() |
|
9 | - { |
|
10 | - Schema::create('regencies', function(Blueprint $table) { |
|
11 | - $table->increments('id'); |
|
12 | - $table->integer('province_id')->unsigned()->nullable()->index(); |
|
13 | - $table->string('name', 191)->index(); |
|
14 | - $table->timestamps(); |
|
15 | - $table->softDeletes(); |
|
16 | - }); |
|
17 | - } |
|
8 | + public function up() |
|
9 | + { |
|
10 | + Schema::create('regencies', function(Blueprint $table) { |
|
11 | + $table->increments('id'); |
|
12 | + $table->integer('province_id')->unsigned()->nullable()->index(); |
|
13 | + $table->string('name', 191)->index(); |
|
14 | + $table->timestamps(); |
|
15 | + $table->softDeletes(); |
|
16 | + }); |
|
17 | + } |
|
18 | 18 | |
19 | - public function down() |
|
20 | - { |
|
21 | - Schema::drop('regencies'); |
|
22 | - } |
|
19 | + public function down() |
|
20 | + { |
|
21 | + Schema::drop('regencies'); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -5,18 +5,18 @@ |
||
5 | 5 | |
6 | 6 | class CreateProvincesTable extends Migration { |
7 | 7 | |
8 | - public function up() |
|
9 | - { |
|
10 | - Schema::create('provinces', function(Blueprint $table) { |
|
11 | - $table->increments('id'); |
|
12 | - $table->string('name', 191)->index(); |
|
13 | - $table->timestamps(); |
|
14 | - $table->softDeletes(); |
|
15 | - }); |
|
16 | - } |
|
8 | + public function up() |
|
9 | + { |
|
10 | + Schema::create('provinces', function(Blueprint $table) { |
|
11 | + $table->increments('id'); |
|
12 | + $table->string('name', 191)->index(); |
|
13 | + $table->timestamps(); |
|
14 | + $table->softDeletes(); |
|
15 | + }); |
|
16 | + } |
|
17 | 17 | |
18 | - public function down() |
|
19 | - { |
|
20 | - Schema::drop('provinces'); |
|
21 | - } |
|
18 | + public function down() |
|
19 | + { |
|
20 | + Schema::drop('provinces'); |
|
21 | + } |
|
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -6,35 +6,35 @@ |
||
6 | 6 | |
7 | 7 | class CreateForeignKeys extends Migration { |
8 | 8 | |
9 | - public function up() |
|
10 | - { |
|
11 | - Schema::table('dashboard_apels', function(Blueprint $table) { |
|
12 | - $table->foreign('province_id')->references('id')->on('provinces') |
|
13 | - ->onDelete('set null') |
|
14 | - ->onUpdate('restrict'); |
|
15 | - }); |
|
16 | - Schema::table('dashboard_apels', function(Blueprint $table) { |
|
17 | - $table->foreign('regency_id')->references('id')->on('regencies') |
|
18 | - ->onDelete('set null') |
|
19 | - ->onUpdate('restrict'); |
|
20 | - }); |
|
21 | - Schema::table('regencies', function(Blueprint $table) { |
|
22 | - $table->foreign('province_id')->references('id')->on('provinces') |
|
23 | - ->onDelete('set null') |
|
24 | - ->onUpdate('restrict'); |
|
25 | - }); |
|
26 | - } |
|
9 | + public function up() |
|
10 | + { |
|
11 | + Schema::table('dashboard_apels', function(Blueprint $table) { |
|
12 | + $table->foreign('province_id')->references('id')->on('provinces') |
|
13 | + ->onDelete('set null') |
|
14 | + ->onUpdate('restrict'); |
|
15 | + }); |
|
16 | + Schema::table('dashboard_apels', function(Blueprint $table) { |
|
17 | + $table->foreign('regency_id')->references('id')->on('regencies') |
|
18 | + ->onDelete('set null') |
|
19 | + ->onUpdate('restrict'); |
|
20 | + }); |
|
21 | + Schema::table('regencies', function(Blueprint $table) { |
|
22 | + $table->foreign('province_id')->references('id')->on('provinces') |
|
23 | + ->onDelete('set null') |
|
24 | + ->onUpdate('restrict'); |
|
25 | + }); |
|
26 | + } |
|
27 | 27 | |
28 | - public function down() |
|
29 | - { |
|
30 | - Schema::table('dashboard_apels', function(Blueprint $table) { |
|
31 | - $table->dropForeign('dashboard_apels_province_id_foreign'); |
|
32 | - }); |
|
33 | - Schema::table('dashboard_apels', function(Blueprint $table) { |
|
34 | - $table->dropForeign('dashboard_apels_regency_id_foreign'); |
|
35 | - }); |
|
36 | - Schema::table('regencies', function(Blueprint $table) { |
|
37 | - $table->dropForeign('regencies_province_id_foreign'); |
|
38 | - }); |
|
39 | - } |
|
28 | + public function down() |
|
29 | + { |
|
30 | + Schema::table('dashboard_apels', function(Blueprint $table) { |
|
31 | + $table->dropForeign('dashboard_apels_province_id_foreign'); |
|
32 | + }); |
|
33 | + Schema::table('dashboard_apels', function(Blueprint $table) { |
|
34 | + $table->dropForeign('dashboard_apels_regency_id_foreign'); |
|
35 | + }); |
|
36 | + Schema::table('regencies', function(Blueprint $table) { |
|
37 | + $table->dropForeign('regencies_province_id_foreign'); |
|
38 | + }); |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -5,23 +5,23 @@ |
||
5 | 5 | |
6 | 6 | class CreateDashboardApelsTable extends Migration { |
7 | 7 | |
8 | - public function up() |
|
9 | - { |
|
10 | - Schema::create('dashboard_apels', function(Blueprint $table) { |
|
11 | - $table->increments('id'); |
|
12 | - $table->string('negara', 191); |
|
13 | - $table->integer('province_id')->unsigned()->nullable()->index(); |
|
14 | - $table->boolean('kab_kota')->index(); |
|
15 | - $table->integer('regency_id')->unsigned()->nullable()->index(); |
|
16 | - $table->string('tahun', 191); |
|
17 | - $table->decimal('data')->index(); |
|
18 | - $table->timestamps(); |
|
19 | - $table->softDeletes(); |
|
20 | - }); |
|
21 | - } |
|
8 | + public function up() |
|
9 | + { |
|
10 | + Schema::create('dashboard_apels', function(Blueprint $table) { |
|
11 | + $table->increments('id'); |
|
12 | + $table->string('negara', 191); |
|
13 | + $table->integer('province_id')->unsigned()->nullable()->index(); |
|
14 | + $table->boolean('kab_kota')->index(); |
|
15 | + $table->integer('regency_id')->unsigned()->nullable()->index(); |
|
16 | + $table->string('tahun', 191); |
|
17 | + $table->decimal('data')->index(); |
|
18 | + $table->timestamps(); |
|
19 | + $table->softDeletes(); |
|
20 | + }); |
|
21 | + } |
|
22 | 22 | |
23 | - public function down() |
|
24 | - { |
|
25 | - Schema::drop('dashboard_apels'); |
|
26 | - } |
|
23 | + public function down() |
|
24 | + { |
|
25 | + Schema::drop('dashboard_apels'); |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -11,12 +11,12 @@ |
||
11 | 11 | 'destroy' => 'Bantenprov\DashboardApel\Http\Controllers\DashboardApelController@destroy', |
12 | 12 | ]; |
13 | 13 | |
14 | - Route::get('/',$controllers->index)->name('dashboard-apel.index'); |
|
15 | - Route::get('/create',$controllers->create)->name('dashboard-apel.create'); |
|
16 | - Route::post('/store',$controllers->store)->name('dashboard-apel.store'); |
|
17 | - Route::get('/{id}',$controllers->show)->name('dashboard-apel.show'); |
|
18 | - Route::put('/{id}/update',$controllers->update)->name('dashboard-apel.update'); |
|
19 | - Route::post('/{id}/delete',$controllers->destroy)->name('dashboard-apel.destroy'); |
|
14 | + Route::get('/', $controllers->index)->name('dashboard-apel.index'); |
|
15 | + Route::get('/create', $controllers->create)->name('dashboard-apel.create'); |
|
16 | + Route::post('/store', $controllers->store)->name('dashboard-apel.store'); |
|
17 | + Route::get('/{id}', $controllers->show)->name('dashboard-apel.show'); |
|
18 | + Route::put('/{id}/update', $controllers->update)->name('dashboard-apel.update'); |
|
19 | + Route::post('/{id}/delete', $controllers->destroy)->name('dashboard-apel.destroy'); |
|
20 | 20 | |
21 | 21 | }); |
22 | 22 |