在nWidart Laravel中执行种子时输出为空

问题描述 投票:0回答:1

我正在使用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);
    }
}

输出为空!

enter image description here

我认为它不会进入LocationsTableSeeder文件,因为当我尝试对它进行dd(1)时,输出也为空

您能帮我吗?

非常感谢!

laravel module package seed
1个回答
0
投票

由于您正在使用laravel/framework 5.7.*,因此您可能需要安装nwidart/laravel-modules ^4.0,因为它是适合您的laravel版本的版本。参见compatibilty

如果仍然无法解决问题,请同时执行此操作:

php artisan db:seed --class=Modules\Settings\Database\Seeders\LocationsTableSeeder

前进

由于您的项目远远落后。我怀疑他们会为此提供任何支持。将您的laravel升级到^7.x,将laravel模块升级到^7.0可能会解决此问题,因为存在issue about this,并且已在最新版本中进行了修复。

© www.soinside.com 2019 - 2024. All rights reserved.