My Blog Posts

Eloquent HasManyDeep Pack

Eloquent HasManyDeep Pack


Country → hasMany → User → hasMany → Post → hasMany → Comment
This has become quite complex, but you can define the relationship with this package as follows:
class Country extends Model
{
    use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

    public function comments()
    {
        return $this->hasManyDeep('App\Comment', ['App\User', 'App\Post']);
    }
}
Then Country::first()->commentsTake all comments that hold the Laravel syntax you have defined you can use it for

More information Obtain Optionally Staudenmeir / eloquent-has-many-deep at Github Visit.



Share this article


Comments (0)

Comment