Last active
May 14, 2020 01:58
-
-
Save beisong7/7215c617d707d4621646b1921989fc0d to your computer and use it in GitHub Desktop.
Laravel Eloquent hasManyThrough
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function staffs(){ | |
return $this->belongsToMany( | |
Staff::class, | |
OrganizationStaff::class, | |
'organization_id', | |
'staff_id', | |
'uuid', | |
'uuid' | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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