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

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -