Output is empty when perform a seed in nWidart Laravel

Viewed 482

I'm using nWidart package to manager Laravel app using modules.

I perform a migrate on Settings module.

php artisan module:make-migration create_locations_table Settings

php artisan module:migrate Settings

It's ok!

When I make a seeder:

php artisan module:make-seed Locations Settings => It worked!

But: 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);
    }
}

The output is empty!

enter image description here

I think it doesn't go to the LocationsTableSeeder file because when I try dd(1) on it, the output is empty too

Can you help me?

Thanks so much!

1 Answers

Since you're using laravel/framework 5.7.*, you might want to install nwidart/laravel-modules ^4.0 as it is the proper version for you laravel version. See compatibilty.

If that still doesn't work, do this for the meantime:

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.

Related