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.

  Quote

KARABAY A, 2019 . Eloquent HasManyDeep Package,

https://www.karabayyazilim.com/blog/php/framework/laravel/eloquent-hasmanydeep-paketi-2019-12-22-115142

(Accessed December 22, 2019).


  Share this post

Comments (0)

Comment

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