Example of HasManyThrough in pterodactyl/panel

File app/Models/Server.php (link to Github)
class Server extends Model
{
    //
    public function mounts()
    {
        return $this->hasManyThrough(Mount::class, MountServer::class, 'server_id', 'id', 'id', 'mount_id');
    }
}
File app/Models/Location.php (link to Github)
class Location extends Model
{
    //
    public function servers()
    {
        return $this->hasManyThrough(Server::class, Node::class);
    }
}

Additional resources on HasManyThrough: