下降模型关系laravel

I am running this query in my laravel app,

$project = Project::leftJoin('organisation_user', 'organisation_user.organisation_id', '=', 'projects.organisation_id')
                ->where('organisation_user.user_id', '=', ResourceServer::getOwnerId())
                ->whereNotNull('projects.organisation_id')
                ->get();

This returns the data that would expect it to, I can then do this load in the pivot data for the organisation the project is related too.

$project->load('organisations');

What I am wanting to do from this point is load in the pivot data for organisations is that possible, in my head it seems like I want to descend through relationships.

You can skip the join and do it all at once assuming you have your many-to-many relationship set up for project and organization models.

$project = Project::has('organizations')->with(['organizations'=> function($query){
    $query->where('user_id', ResourceServer::getOwnerId());
}])->get();

Or, change things up a bit and call nested relationships.

$organization = Organization::with('projects.organizations')->where('user_id', ResourceServer::getOwnerId())->first();

return $organization->projects;

If you need additional pivot table data included, you can add withPivot() to your relationships.