Reputation: 30568
For example, I have a User
has many Comments
, but I would like to query the Comment
is status 1 only. How can I do that using Eloquent ORM in Laravel? Thanks
Upvotes: 0
Views: 574
Reputation: 682
Use something like
$user->comments()->where('status', 1)->get();
By adding the parenthesis after comments you will receive a QueryBuilder instance instead of a Collection of results.
Upvotes: 3