To remove an anonymous global scope when using the with() method in Eloquent, you can use the withoutGlobalScope() method. However, since you're dealing with a relationship, you'll need to apply this method within a closure passed to with(). Here's how you can modify your query to remove the is_user_owner global scope from the CandidateProfile model:
$applicants = Application::query()
->with(['user.candidate_profile' => function ($query) {
$query->withoutGlobalScope('is_user_owner');
}])
->where('job_id', $job->id)
->get();
In this code, the withoutGlobalScope('is_user_owner') method is used within the closure to remove the specific global scope from the CandidateProfile model when fetching the related data. This allows you to retrieve the CandidateProfile records without the constraint imposed by the is_user_owner global scope.