Reputation: 9
I try to insert with code
$info = DB::table('role_user')->where('user_id', '=',$current)
->where('role_id', '=',$id)->get();
error of insert
$response = $info->insert(array('active' => 1));
Upvotes: 0
Views: 5391
Reputation: 91
You should run the update query:
$response = DB::table('role_user')
->where('user_id', $current)
->where('role_id', $id)
->update(array('active' => 1));
Upvotes: 1
Reputation: 4620
You can't insert the same role_user
twice, but you can update
it
$response = DB::table('role_user')->where('user_id', '=',$current)
->where('role_id', '=',$id)->update(array('active' => 1));
Upvotes: 2