Hi, I've tried everything, the same error occurs.
" In SeedCommand.php line 177:
Type error: Argument 1 passed to NwidartModulesCommandsSeedCommand::reportException() must be an instance of Exception, instance of Er
ror given, called in F:laragonwwwrhemavendornwidartlaravel-modulessrcCommandsSeedCommand.php on line 50 "
namespace ModulesUserDatabaseSeeders;
use IlluminateDatabaseSeeder;
use IlluminateDatabaseEloquentModel;
use ModulesUserDatabaseSeedersUserTableSeeder;
class UserDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
//$this->call("UserTableSeeder");
User::create([
'name' => 'Admin',
'email' => '[email protected]',
'password' => bcrypt(123456)
]);
}
}
Could someone help me?
I've tried creating the UserTableSeeder class but the same error occurs.
I'm getting same error
Type error: Argument 1 passed to Nwidart\Modules\Commands\SeedCommand::reportException() must be an instance of Exception, instance of Error given, called in /home/vagrant/sites/pq/
vendor/nwidart/laravel-modules/src/Commands/SeedCommand.php on line 50
Unable to seed Module based seeders.
im get same error
Feel free to send a pull request guys :)
for now I do it like so:
php artisan db:seed --class=\\Modules\\Mymodule\\Database\\Seeders\\MymoduleDatabaseSeeder
I was able to run the module:seed command with no issues here. How exactly could I reproduce the issue?
I had the same problem when following laravel documentation; then I realized I forgot to use the DB class.
On UserTableSeeder.php:
use IlluminateSupportFacadesDB;
Works for me =)
I think it's because Error does not inherit from Exception in PHP 7. But both of them inherit from Throwable, however it is not supported on PHP 5.
Laravel still uses Exception rather than Throwable in their handler. Maybe in the future, when Laravel is in pure PHP 7.
Seeding: ModulesPackageDatabaseSeedersPackageDataSeeders
In SeedCommand.php line 177:
Type error: Argument 1 passed to NwidartModulesCommandsSeedCommand::repo
rtException() must be an instance of Exception, instance of Error given, ca
lled in C:wamp64wwwwprojectstravelvendornwidartlaravel-modulessrcC
ommandsSeedCommand.php on line 50
Why was changed the namespace of created seeders from $NAMESPACE$DatabaseSeeders; to namespace $NAMESPACE$;?
This is getting replaced by the command now.
I'll close this as it was fixed. If not feel free to re-comment and I'll re-open.
Issue still there in release 2.7.0. I am using laravel 5.5 with php 7.2.6.
Now tried with 3.2 with laravel 5.6 using php 7.2.6. Issue persists
+1
facing same issue. Anyone have a complete example to the workaround or solution of the issue?
+1
Same issue with Laravel 5.6 and php 7.2*
Appears to be the same issue with L5.7 php 7.2 - when seeding.
Argument 1 passed to NunoMaduroCollisionAdaptersLaravelExceptionHandler::report() must be an instance of Exception, instance of Error given, called in /home/dev/public_html/vendor/nwidart/laravel-modules/src/Commands/SeedCommand.php on line 180
Same issue... Laravel 5.6.x and PHP 7.2.x
+1
I am getting the same issue. I am using PHP 7.1.13 CLI and Laravel 5.7.15
Below Is my CMS Module Main Seeder
<?php
namespace Modules\CMS\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class CMSDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call(CommentsTableSeeder::class);
}
}
Comments Seeder
<?php
namespace Modules\CMS\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
// use Illuminate\Database\Eloquent\Model;
class CommentsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//What is unguard ?
//Model::unguard();
$lipsum = new joshtronic\LoremIpsum();
DB::table('comments')->insert([
'post_id'=>3,
'username' => 'Anthony Bordane',
'comment' => $lipsum->sentences(3),
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
}
}
Command
php artisan module:seed CMS
Just to add some thoughts.. I had the same thing today.... while I KNEW it worked yesterday... so I could easily backtrack the changes. Apparently there was a syntax error in my ModuleSeeder.php.
After fixing the syntax error it worked again
well @robov I definitely took in what you said and that definitely was my issue as well. It appears my class $lipsum = new joshtronic\LoremIpsum(); needed to add the backslash at the beginning like so $lipsum = new \joshtronic\LoremIpsum(); . In conclusion I would say anyone who has this issue more then likely has a error some where in their document. The Exception just probably needs to be caught and logged to know specifically what it is.
Change $this->call("LanguagesTableSeeder"); to $this->call(LanguagesTableSeeder::class);
and php artisan module:seed <_ModuleName_>
Laravel : 5.7.19
laravel/modules : 4.0-dev
I also faced the same issues listed above with similar errors..
after few tries, i was able to run the seeder in the Modules/dashboard successfully.
ContactsFactory.php
<?php
use Faker\Generator as Faker;
$factory->define(Modules\Dashboard\Entities\Contacts::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'phone' => $faker->e164PhoneNumber,
'age' => $faker->numberBetween(18, 55),
'gender' => $faker->randomElement($array = array ('male','female','other'))
];
});
ContactsTableSeeder.php
<?php
namespace Modules\Dashboard\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Modules\Dashboard\Entities\Contacts;
class ContactsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$contacts = factory(Contacts::class, 35000)->create();
//Model::unguard();
// $this->call("OthersTableSeeder");
}
}
DashboardDatabaseSeeder.php (Main seeder file in Modules/dashboard)
<?php
namespace Modules\Dashboard\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DashboardDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call("Modules\Dashboard\Database\Seeders\ContactsTableSeeder");
}
}
I try to use "use IlluminateSupportFacadesDB;"
but didn't work
then i try to use back slash, it work for me
\DB::table('...')->insert([...
I really do not understand too why the error keeps repeating. @nWidart please help us out on how to remove the error. Even the seeder classes generated with the module:make-seed get the Class reflection error
Until then a temporary fix is to just use the seeder generated in the module and not otherwise.
_Also for all those who are getting the exception or throwable errors please be sure to check your models first. Seeding a module that has a dependency on another module will always give you the throwable error._
I faced the same problem. After some moment I figured out one thing, I missed one of my used Model.
@nWidart, In that case, it should say, the model 'Tried_to_create_data' is not found.
hey guys,
i got it my custom seeder class working.
to insert seeded data you'll need to define it in module.json
{
"name": "Rates",
"alias": "rates",
.
.
.
"migration": {
"seeds": [
"Modules\\Rates\\database\\seeds\\v1\\DatabaseSeeder"
]
}
}
then run command
php artisan module:seed Rates to seed all the seeders defined there or
php artisan module:seed Rates --class=DatabaseSeeder to seed one single seeder.
the key here is to define your seeder classes in module.json
i suppose this should be added to the docs as well @nWidart
in my case when module in subfolders and want to run in directly without running other seeder
php artisan db:seed --class=WM\Common\Seeder\SmsStatusSeeder
Most helpful comment
I had the same problem when following laravel documentation; then I realized I forgot to use the DB class.
On UserTableSeeder.php:
use IlluminateSupportFacadesDB;
Works for me =)