在 nWidart 中执行种子时输出为空 Laravel
Output is empty when perform a seed in nWidart Laravel
我正在使用 nWidart 包来管理使用模块的 Laravel 应用程序。
我在设置模块上执行迁移。
php artisan module:make-migration create_locations_table Settings
php artisan module:migrate Settings
没关系!
当我制作播种机时:
php artisan module:make-seed Locations Settings
=> 成功了!
但是:php artisan module:seed Settings
<?php
namespace Modules\Settings\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class LocationsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
$data = [
'id' => '1',
'name' => 'Hà Nội',
'parent_id' => NULL,
'type' => '1',
'district_id' => NULL,
'province_id' => NULL,
'country_id' => '79162',
'created_at' => '2020-03-26 12:01:08',
'updated_at' => '2020-03-26 12:01:08'
];
DB::table('locations')->insert($data);
}
}
输出为空!
我认为它不会转到 LocationsTableSeeder 文件,因为当我尝试 dd(1)
它时,输出也是空的
你能帮帮我吗?
非常感谢!
由于您使用的是 laravel/framework 5.7.*
,您可能需要安装 nwidart/laravel-modules ^4.0
,因为它是适合您的 laravel 版本。参见 compatibilty。
如果还是不行,请暂时执行以下操作:
php artisan db:seed --class=Modules\Settings\Database\Seeders\LocationsTableSeeder
Way forward
Since your project is pretty far behind. I doubt that they will provide any support for this anymore. Upgrading your laravel to ^7.x
and laravel-modules to ^7.0
may fix this since there had been an issue about this and has been fixed in the latest versions.
我正在使用 nWidart 包来管理使用模块的 Laravel 应用程序。
我在设置模块上执行迁移。
php artisan module:make-migration create_locations_table Settings
php artisan module:migrate Settings
没关系!
当我制作播种机时:
php artisan module:make-seed Locations Settings
=> 成功了!
但是:php artisan module:seed Settings
<?php
namespace Modules\Settings\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class LocationsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
$data = [
'id' => '1',
'name' => 'Hà Nội',
'parent_id' => NULL,
'type' => '1',
'district_id' => NULL,
'province_id' => NULL,
'country_id' => '79162',
'created_at' => '2020-03-26 12:01:08',
'updated_at' => '2020-03-26 12:01:08'
];
DB::table('locations')->insert($data);
}
}
输出为空!
我认为它不会转到 LocationsTableSeeder 文件,因为当我尝试 dd(1)
它时,输出也是空的
你能帮帮我吗?
非常感谢!
由于您使用的是 laravel/framework 5.7.*
,您可能需要安装 nwidart/laravel-modules ^4.0
,因为它是适合您的 laravel 版本。参见 compatibilty。
如果还是不行,请暂时执行以下操作:
php artisan db:seed --class=Modules\Settings\Database\Seeders\LocationsTableSeeder
Way forward
Since your project is pretty far behind. I doubt that they will provide any support for this anymore. Upgrading your laravel to
^7.x
and laravel-modules to^7.0
may fix this since there had been an issue about this and has been fixed in the latest versions.