Eloquent HasManyDeep Pack

Country → hasMany → User → hasMany → Post → hasMany → Comment
This has become quite complicated, but you can define the relationship with this package as follows:
classCountryextendsModel{ use \Staudenmeir\EloquentHasManyDeep\HasRelationships; publicfunctioncomments(){ return$this->hasManyDeep('App\Comment', ['App\User', 'App\Post']); }}
after Country::first()->comments, we have defined Laravel to receive all comments that hold the syntax you can use it for

More information get Optionally Staudenmeir / eloquent-has-many-deep on Github Visit.


KARABAY A, 2019 . Eloquent HasManyDeep Package,


(Accessed December 22, 2019).

  Share this post

Comments (0)


Sign up for the email newsletter to be the first to know about my blog posts