I want detach without some records
my role_user table is id | role_id | user_id
<?php
$user->roles()->detach();
?>
I don't want detach all records some records need (I mean find solution to where clause inside detach() ). How can I do this? Thank you.
Finnaly I found the solution
$user->roles()->wherePivot('role_id', '!=', 3)->detach();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With