Reputation: 12015
I have checked out, class PermissionsTableSeeder
exists by path: Database\Seeds\PermissionsTableSeeder
.
Also, I tried:
composer dump-autoload
php artisan cache:clear
When I run command: php artisan db:seed
it gives me an exception:
ReflectionException : Class Database\Seeds\PermissionsTableSeeder does not exist
at C:\Projects\secure_secure\vendor\laravel\framework\src\Illuminate\Container\Container.php:790 786| if ($concrete instanceof Closure) { 787| return $concrete($this, $this->getLastParameterOverride()); 788| } 789|
790| $reflector = new ReflectionClass($concrete); 791| 792| // If the type is not instantiable, the developer is attempting to resolve 793| // an abstract type such as an Interface or Abstract Class and there is 794| // no binding registered for the abstractions so we need to bail out.
Exception trace:
1
ReflectionClass::__construct("Database\Seeds\PermissionsTableSeeder") C:\Projects\secure_secure\vendor\laravel\framework\src\Illuminate\Container\Container.php:7902
Illuminate\Container\Container::build("Database\Seeds\PermissionsTableSeeder") C:\Projects\secure_secure\vendor\laravel\framework\src\Illuminate\Container\Container.php:667
How to fix it?
Upvotes: 2
Views: 6425
Reputation: 534
I changed database/seeds/DatabaseSeeder.php
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Database\Seeds\PermissionsTableSeeder;
use Database\Seeds\RolesTableSeeder;
use Database\Seeds\ConnectRelationshipsSeeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call(PermissionsTableSeeder::class);
$this->call(RolesTableSeeder::class);
$this->call(ConnectRelationshipsSeeder::class);
//$this->call('UsersTableSeeder');
Model::reguard();
}
}
to
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Database\Seeds\PermissionsTableSeeder;
use Database\Seeds\RolesTableSeeder;
use Database\Seeds\ConnectRelationshipsSeeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call('PermissionsTableSeeder');
$this->call('RolesTableSeeder');
$this->call('ConnectRelationshipsSeeder');
//$this->call('UsersTableSeeder');
Model::reguard();
}
}
This fixed my Error
php artisan db:seed
Seeding: DefaultPermissionitemsTableSeeder
Seeding: DefaultRoleItemsTableSeeder
Seeding: DefaultConnectRelationshipsSeeder
Seeding: DefaultConnectRelationshipsSeeder - Role:Admin attached to Permission:view.users
Seeding: DefaultConnectRelationshipsSeeder - Role:Admin attached to Permission:create.users
Seeding: DefaultConnectRelationshipsSeeder - Role:Admin attached to Permission:edit.users
Seeding: DefaultConnectRelationshipsSeeder - Role:Admin attached to Permission:delete.users
Seeding: PermissionsTableSeeder
ReflectionException : Class Database\Seeds\RolesTableSeeder does not exist
at D:\Work\Coding\Laravel\Epox\vendor\laravel\framework\src\Illuminate\Container\Container.php:788
784| if ($concrete instanceof Closure) {
785| return $concrete($this, $this->getLastParameterOverride());
786| }
787|
> 788| $reflector = new ReflectionClass($concrete);
789|
790| // If the type is not instantiable, the developer is attempting to resolve
791| // an abstract type such as an Interface or Abstract Class and there is
792| // no binding registered for the abstractions so we need to bail out.
Exception trace:
1 ReflectionClass::__construct("Database\Seeds\RolesTableSeeder")
D:\Work\Coding\Laravel\Epox\vendor\laravel\framework\src\Illuminate\Container\Container.php:788
2 Illuminate\Container\Container::build("Database\Seeds\RolesTableSeeder")
D:\Work\Coding\Laravel\Epox\vendor\laravel\framework\src\Illuminate\Container\Container.php:667
Please use the argument -v to see more details.
to
php artisan db:seed
Seeding: DefaultPermissionitemsTableSeeder
Seeding: DefaultRoleItemsTableSeeder
Seeding: DefaultConnectRelationshipsSeeder
Seeding: DefaultConnectRelationshipsSeeder - Role:Admin attached to Permission:view.users
Seeding: DefaultConnectRelationshipsSeeder - Role:Admin attached to Permission:create.users
Seeding: DefaultConnectRelationshipsSeeder - Role:Admin attached to Permission:edit.users
Seeding: DefaultConnectRelationshipsSeeder - Role:Admin attached to Permission:delete.users
Seeding: PermissionsTableSeeder
Seeding: RolesTableSeeder
Seeding: ConnectRelationshipsSeeder
php artisan --version
Laravel Framework 5.8.36
Upvotes: 0
Reputation: 9161
There is no Database\Seeds\
namespace in laravel, and seeders have no namespace by default.
Please check DatabaseSeeder.php
you should have this function:
public function run()
{
.....
$this->call(PermissionsTableSeeder::class);
}
Check also that you have not given any namespace to the DatabaseSeeder
class or to the PermissionsTableSeeder
class.
You shoud remove also any line that start with use Database\Seeds
in you DatabaseSeeder.php
because that namespace does not exist.
Upvotes: 8