Skip to content

Commit

Permalink
Merge pull request azishapidin#17 from iMushlih/master
Browse files Browse the repository at this point in the history
Support Laravel 8
  • Loading branch information
azishapidin authored Feb 24, 2021
2 parents ebe4f4a + 6e834a7 commit d56eb2e
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CreateProvincesTables extends Migration
*/
public function up()
{
Schema::create('indoregion_provinces', function(Blueprint $table){
Schema::create('provinces', function(Blueprint $table){
$table->char('id', 2)->index();
$table->string('name');
});
Expand All @@ -33,6 +33,6 @@ public function up()
*/
public function down()
{
Schema::drop('indoregion_provinces');
Schema::drop('provinces');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ class CreateRegenciesTables extends Migration
*/
public function up()
{
Schema::create('indoregion_regencies', function(Blueprint $table){
Schema::create('regencies', function(Blueprint $table){
$table->char('id', 4)->index();
$table->char('province_id', 2);
$table->string('name', 50);
$table->foreign('province_id')
->references('id')
->on('provinces')
->onUpdate('cascade')->onDelete('restrict');
});
}

Expand All @@ -34,6 +38,6 @@ public function up()
*/
public function down()
{
Schema::drop('indoregion_regencies');
Schema::drop('regencies');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ class CreateDistrictsTables extends Migration
*/
public function up()
{
Schema::create('indoregion_districts', function(Blueprint $table){
Schema::create('districts', function(Blueprint $table){
$table->char('id', 7)->index();
$table->char('regency_id', 4);
$table->string('name', 50);
$table->foreign('regency_id')
->references('id')
->on('regencies')
->onUpdate('cascade')->onDelete('restrict');
});
}

Expand All @@ -34,6 +38,6 @@ public function up()
*/
public function down()
{
Schema::drop('indoregion_districts');
Schema::drop('districts');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ class CreateVillagesTables extends Migration
*/
public function up()
{
Schema::create('indoregion_villages', function(Blueprint $table){
Schema::create('villages', function(Blueprint $table){
$table->char('id', 10)->index();
$table->char('district_id', 7);
$table->string('name', 50);
$table->foreign('district_id')
->references('id')
->on('districts')
->onUpdate('cascade')->onDelete('restrict');
});
}

Expand All @@ -34,6 +38,6 @@ public function up()
*/
public function down()
{
Schema::drop('indoregion_villages');
Schema::drop('villages');
}
}
2 changes: 1 addition & 1 deletion src/database/models/District.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class District extends Model
*
* @var string
*/
protected $table = 'indoregion_districts';
protected $table = 'districts';

/**
* The attributes that should be hidden for arrays.
Expand Down
2 changes: 1 addition & 1 deletion src/database/models/Province.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Province extends Model
*
* @var string
*/
protected $table = 'indoregion_provinces';
protected $table = 'provinces';

/**
* Province has many regencies.
Expand Down
2 changes: 1 addition & 1 deletion src/database/models/Regency.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Regency extends Model
*
* @var string
*/
protected $table = 'indoregion_regencies';
protected $table = 'regencies';

/**
* The attributes that should be hidden for arrays.
Expand Down
2 changes: 1 addition & 1 deletion src/database/models/Village.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Village extends Model
*
* @var string
*/
protected $table = 'indoregion_villages';
protected $table = 'villages';

/**
* The attributes that should be hidden for arrays.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*
*/

namespace Database\Seeders;
use Illuminate\Database\Seeder;
use AzisHapidin\IndoRegion\RawDataGetter;
use Illuminate\Support\Facades\DB;

class IndoRegionDistrictSeeder extends Seeder
{
Expand All @@ -25,6 +27,6 @@ public function run()
$districts = RawDataGetter::getDistricts();

// Insert Data to Database
DB::table('indoregion_districts')->insert($districts);
DB::table('districts')->insert($districts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*
*/

namespace Database\Seeders;
use Illuminate\Database\Seeder;
use AzisHapidin\IndoRegion\RawDataGetter;
use Illuminate\Support\Facades\DB;

class IndoRegionProvinceSeeder extends Seeder
{
Expand All @@ -25,6 +27,6 @@ public function run()
$provinces = RawDataGetter::getProvinces();

// Insert Data to Database
DB::table('indoregion_provinces')->insert($provinces);
DB::table('provinces')->insert($provinces);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*
*/

namespace Database\Seeders;
use Illuminate\Database\Seeder;
use AzisHapidin\IndoRegion\RawDataGetter;
use Illuminate\Support\Facades\DB;

class IndoRegionRegencySeeder extends Seeder
{
Expand All @@ -25,6 +27,6 @@ public function run()
$regencies = RawDataGetter::getRegencies();

// Insert Data to Database
DB::table('indoregion_regencies')->insert($regencies);
DB::table('regencies')->insert($regencies);
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*
*/

namespace Database\Seeders;
use Illuminate\Database\Seeder;
use AzisHapidin\IndoRegion\RawDataGetter;
use Illuminate\Support\Facades\DB;

class IndoRegionVillageSeeder extends Seeder
{
Expand All @@ -29,7 +31,7 @@ public function run()
$collection = collect($villages);
$parts = $collection->chunk(1000);
foreach ($parts as $subset) {
DB::table('indoregion_villages')->insert($subset->toArray());
DB::table('villages')->insert($subset->toArray());
}
});
}
Expand Down

0 comments on commit d56eb2e

Please sign in to comment.