I have a parent table and a child table with the eloquent models set up as:
class Parent extends Eloquent {
public function children()
{
return $this->hasMany('child');
}
}
class Child extends Eloquent {
public function parent()
{
return $this->belongsTo('parent');
}
}
How can I return only parent rows that have 1 or more children?
From documentation You do it like this :
$parents = Parent::has('children')->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With