Skip to content

Instantly share code, notes, and snippets.

@beisong7
Last active May 14, 2020 01:58
Show Gist options
  • Save beisong7/7215c617d707d4621646b1921989fc0d to your computer and use it in GitHub Desktop.
Save beisong7/7215c617d707d4621646b1921989fc0d to your computer and use it in GitHub Desktop.
Laravel Eloquent hasManyThrough
public function staffs(){
return $this->belongsToMany(
Staff::class,
OrganizationStaff::class,
'organization_id',
'staff_id',
'uuid',
'uuid'
);
}
public function organization(){
return $this->hasManyThrough(
Organization::class,
OrganizationStaff::class,
'staff_id',
'uuid',
'uuid',
'organization_id'
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment