Laravel 5.1 detach with where -
i want detach without records
my role_user table id | role_id | user_id
<?php $user->roles()->detach(); ?>
i don't want detach records records need (i mean find solution clause inside detach() ). how can this? thank you.
finnaly found solution
$user->roles()->wherepivot('role_id', '!=', 3)->detach();
Comments
Post a Comment