Route::get('/inser_role', function () {
$Role = Role::create([
'name'=>'super'
]);
$user = new User;
return $user->Role()->sync([2,$Role]);
});
يطلع خطا ابغا اجرب هذي
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'users_id' cannot be null (SQL: insert into `role_users` (`roles_id`, `users_id`) values (2, ?))
Route::get('/inser_role', function () {
$Role = Role::create([
'name'=>'super'
]);
$user = new User;
return $user->Role()->sync([2,2]);
});