vault; /** @var User $user */ $user = $vault->user; $relativePath = ''; if ($node->parent) { /** * @var string $fullPath * * @phpstan-ignore-next-line larastan.noUnnecessaryCollectionCall */ $fullPath = $node->parent->ancestorsAndSelf()->get()->last()->full_path; $relativePath = $fullPath . '/'; } $path = sprintf( 'private/vaults/%u/%s/%s', $user->id, $vault->name, $relativePath, ); if ($includeSelf) { $path .= $node->name . ($node->is_file ? '.' . $node->extension : ''); } return $path; } }