with(['pressRelease' => fn ($query) => $query ->withoutGlobalScope(PortalScope::class) ->with(['company' => fn ($company) => $company->withoutGlobalScope(PortalScope::class)])]) ->findOrFail($attachment); $pressRelease = $attachment->pressRelease; abort_unless($pressRelease instanceof PressRelease, 404); $isPublic = $this->pressReleaseMediaIsPublic($pressRelease); $this->authorizePressReleaseMediaAccess($request, $pressRelease, $isPublic); return Storage::disk($attachment->disk)->download( $attachment->path, $attachment->original_name, [ 'Cache-Control' => $this->mediaCacheControl($isPublic), 'X-Content-Type-Options' => 'nosniff', ], ); } }