Create a Ladill folder when uploading a local folder and place files inside it.
Deploy Ladill Transfer / deploy (push) Successful in 27s
Deploy Ladill Transfer / deploy (push) Successful in 27s
Folder upload now names and creates the destination folder from the picked directory, uploads all files into it, and redirects to the new folder view. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -59,6 +59,39 @@ class FileStorageService
|
||||
]);
|
||||
}
|
||||
|
||||
public function createFolderForUpload(User $user, string $name): Transfer
|
||||
{
|
||||
$title = trim($name);
|
||||
if ($title === '') {
|
||||
throw new RuntimeException('Enter a folder name.');
|
||||
}
|
||||
|
||||
return $this->createFolder($user, $this->uniqueFolderTitle($user, $title));
|
||||
}
|
||||
|
||||
public function uniqueFolderTitle(User $user, string $title): string
|
||||
{
|
||||
$candidate = $title;
|
||||
$counter = 1;
|
||||
|
||||
while ($this->folderTitleExists($user, $candidate)) {
|
||||
$candidate = $title.' ('.$counter.')';
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $candidate;
|
||||
}
|
||||
|
||||
private function folderTitleExists(User $user, string $title): bool
|
||||
{
|
||||
return Transfer::query()
|
||||
->where('user_id', $user->id)
|
||||
->where('is_folder', true)
|
||||
->where('status', '!=', Transfer::STATUS_DELETED)
|
||||
->where('title', $title)
|
||||
->exists();
|
||||
}
|
||||
|
||||
public function uploadDestination(User $user, ?Transfer $folder): Transfer
|
||||
{
|
||||
if ($folder !== null) {
|
||||
|
||||
Reference in New Issue
Block a user