Last active
March 17, 2023 07:09
-
-
Save DarkGhostHunter/ce34cbe022d29afa852c479704ccaca3 to your computer and use it in GitHub Desktop.
958dd096db-User
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
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class User extends Model | |
{ | |
// ... | |
/** | |
* The the Audio Files the user has from their subscribed podcasts. | |
*/ | |
public function audioFiles() | |
{ | |
return $this->hasManyThrough( | |
'App\AudioFiles', // The model to access to | |
'App\Pivots\Subscription', // The intermediate table that connects the User with the Podcast. | |
'user_id', // The column of the intermediate table that connects to this model by its ID. | |
'podcast_id', // The column of the intermediate table that connects the Podcast by its ID. | |
'id', // The column that connects this model with the intermediate model table. | |
'podcast_id' // The column of the Audio Files table that ties it to the Podcast. | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👌