From a5c71a7633ed3f952e62db89463363b8592bb1e0 Mon Sep 17 00:00:00 2001 From: pratiksh404 Date: Sun, 18 Oct 2020 10:09:33 +0545 Subject: [PATCH] v_1.0.1 --- README.md | 19 +++---------------- config/LaraNepal.php | 10 +++++++++- ...20_10_14_000000_create_provinces_table.php | 8 +++++--- ...20_10_14_000099_create_districts_table.php | 8 +++++--- ..._14_000100_create_municipalities_table.php | 8 +++++--- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 09d59a2..0f11e88 100644 --- a/README.md +++ b/README.md @@ -18,26 +18,13 @@ then publish the package seeds php artisan import:nepal ``` -then call them in DatabaseSeeder.php +then migrate the tables ```sh - class DatabaseSeeder extends Seeder -{ - /** - * Seed the application's database. - * - * @return void - */ - public function run() - { - $this->call(ProvinceSeeder::class); - $this->call(DistrictSeeder::class); - $this->call(MunicipalitySeeder::class); - } -} +php artisan migrate ``` -that's it you are good to go +that's it, you are good to go. `Note` if seeder not found run `composer dump-autoload` diff --git a/config/LaraNepal.php b/config/LaraNepal.php index 585a506..b2f9082 100644 --- a/config/LaraNepal.php +++ b/config/LaraNepal.php @@ -7,5 +7,13 @@ |-------------------------------------------------------------------------- | */ - 'caching' => true + 'caching' => true, + + /* + |-------------------------------------------------------------------------- + | Seed in migration + |-------------------------------------------------------------------------- + | + */ + 'seeding_while_migration' => true ]; diff --git a/database/migrations/2020_10_14_000000_create_provinces_table.php b/database/migrations/2020_10_14_000000_create_provinces_table.php index 26bc2ee..3376e84 100644 --- a/database/migrations/2020_10_14_000000_create_provinces_table.php +++ b/database/migrations/2020_10_14_000000_create_provinces_table.php @@ -25,9 +25,11 @@ public function up() }); // Seeder Artisan Call - Artisan::call('db:seed', [ - '--class' => ProvinceSeeder::class - ]); + if (config('laranepal.seeding_while_migration', true)) { + Artisan::call('db:seed', [ + '--class' => ProvinceSeeder::class + ]); + } } /** diff --git a/database/migrations/2020_10_14_000099_create_districts_table.php b/database/migrations/2020_10_14_000099_create_districts_table.php index 6452713..76efaf0 100644 --- a/database/migrations/2020_10_14_000099_create_districts_table.php +++ b/database/migrations/2020_10_14_000099_create_districts_table.php @@ -25,9 +25,11 @@ public function up() }); // Seeder Artisan Call - Artisan::call('db:seed', [ - '--class' => DistrictSeeder::class - ]); + if (config('laranepal.seeding_while_migration', true)) { + Artisan::call('db:seed', [ + '--class' => DistrictSeeder::class + ]); + } } /** diff --git a/database/migrations/2020_10_14_000100_create_municipalities_table.php b/database/migrations/2020_10_14_000100_create_municipalities_table.php index bdc8b9e..5e2a4e1 100644 --- a/database/migrations/2020_10_14_000100_create_municipalities_table.php +++ b/database/migrations/2020_10_14_000100_create_municipalities_table.php @@ -24,9 +24,11 @@ public function up() }); // Seeder Artisan Call - Artisan::call('db:seed', [ - '--class' => MunicipalitySeeder::class - ]); + if (config('laranepal.seeding_while_migration', true)) { + Artisan::call('db:seed', [ + '--class' => MunicipalitySeeder::class + ]); + } } /**