Last active
April 9, 2020 14:07
-
-
Save ricardoaugusto/f799e51db4531d91771e03c12ac71761 to your computer and use it in GitHub Desktop.
Laravel HasManyThrough explanation
This file contains 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
class Current extends Model | |
{ | |
public function final() | |
{ | |
return $this->hasManyThrough( | |
'App\Final', | |
'App\Intermediate', | |
'intermediate_id', // Foreign key on Intermediate | |
'final_id', // Foreign key on Final | |
'id', // Local key on Current | |
'id' // Local key on Intermediate | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because I'm always forgetting those keys.