vault); if (!$request->has('path')) { abort(404); } /** @var string $path */ $path = $request->path; if (!str_starts_with($path, '/') && $request->has('node')) { /** @var VaultNode $node */ $node = $vault->nodes()->findOrFail($request->node); if ($node->vault_id !== $vault->id) { abort(404); } /** * @var string $currentPath * * @phpstan-ignore-next-line larastan.noUnnecessaryCollectionCall */ $currentPath = $node->ancestorsAndSelf()->get()->last()->full_path; $path = new ResolveTwoPaths()->handle($currentPath, $path); } /** @var VaultNode $node */ $node = new GetVaultNodeFromPath()->handle($vault->id, $path); $relativePath = new GetPathFromVaultNode()->handle($node); $absolutePath = Storage::disk('local')->path($relativePath); ob_end_clean(); return response()->file($absolutePath); } }