Laravel Eloquent, select only rows where the relation exists
According to Laravel's Eloquent documentation for querying relationship existence, you can use the has()
method for this:
User::has('comments')->paginate(20);
According to Laravel's Eloquent documentation for querying relationship existence, you can use the has()
method for this:
User::has('comments')->paginate(20);