php - Laravel Eloquent WHERE and AND -
i have comment table id, privacy(0,1,2), comment_body
columns
i using larvael 4.2.x
eloquent result. trying comment privacy of 0 , 1 one user.
what have tried?
option 1
$user = user::find(1); //query give me comment privacy = 0 $comment_for_user = $user->comments()->where('privacy','0');
option 2
//this wont return $comment_for_user = $user->comments()->where('privacy','0') ->where('privacy',1);
option 3
//return result gets post form users $comment_for_user = $user->comments()->where('privacy','0') ->orwhere('privacy',1);
thanks help.
you can use wherein
.
$comment_for_user = $user->comments()->wherein('privacy', array(0, 1))->get();
you can find more useful methods in documentation.
Comments
Post a Comment