A
A
Anon33632020-08-15 14:47:06
Laravel
Anon3363, 2020-08-15 14:47:06

Trying to create Role and Permissions for a site with php artisan db:seed getting an error?

Error

$ php artisan db:seed
Seeding: RoleSeeder
Seeded: RoleSeeder (0.13 seconds)
Seeding: PermissionSeeder
Seeded: PermissionSeeder (0.18 seconds)
Seeding: UserSeeder

Illuminate\Database\QueryException

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null (SQL: insert into `users_roles` (`role_id`, `user_id`) values ​​(1, ?))

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexey Ukolov, 2020-08-15
@Anon3363

$user2->roles()->attach($manager);
$user2->permissions()->attach($mangeUsers);

The user must be saved first, as in the first case.

H
hbmozg, 2015-04-17
@hbmozg

frootvpn

A
Alexey, 2015-04-17
@ZeLib0ba

https://vpntunnel.com

A
Arman Toksimbaev, 2015-06-17
@toxicdream

shadeyouvpn.com

I
isyukal, 2016-02-24
@isyukal

VPN www.securevpn.pro recommend for cooperation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question