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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -