I am using Zizaco/Entrust in Laravel 5.0 to apply RBAC and i'm having the following error:
Cannot insert the value NULL into column 'user_id', table 'dbo.role_user'; column does not allow nulls. INSERT fails. (SQL: insert into [role_user] ([role_id], [user_id]) values (2, ))
I followed all the steps to implement Entrust and at my User.php
store method i have:
public function store(UserRequest $request)
{
$user = new User();
$user->create($request->all());
$roles=$request->get('role_id');
$user->roles->attach($roles);
return redirect('users');
}
I want to know how can I fix this issue. All the help is appreciated.