user(); /** @var Vault $vault */ $vault = $node->vault; $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', $currentUser->id, $vault->name, $relativePath, ); if ($includeSelf) { $path .= $node->name . ($node->is_file ? '.' . $node->extension : ''); } return $path; } }