Skip to content

Commit fd657d1

Browse files
committed
fix namespace
1 parent a53ec52 commit fd657d1

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

src/Controllers/ItemsController.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
namespace UniSharp\LaravelFilemanager\Controllers;
44

5+
use UniSharp\LaravelFilemanager\Events\FileIsMoving;
6+
use UniSharp\LaravelFilemanager\Events\FileWasMoving;
7+
use UniSharp\LaravelFilemanager\Events\FolderIsMoving;
8+
use UniSharp\LaravelFilemanager\Events\FolderWasMoving;
9+
510
class ItemsController extends LfmController
611
{
712
/**
@@ -19,4 +24,56 @@ public function getItems()
1924
'working_dir' => $this->lfm->path('working_dir'),
2025
];
2126
}
27+
28+
public function move()
29+
{
30+
$items = request('items');
31+
$folder_types = array_filter(['user', 'share'], function ($type) {
32+
return $this->helper->allowFolderType($type);
33+
});
34+
return view('laravel-filemanager::move')
35+
->with([
36+
'root_folders' => array_map(function ($type) use ($folder_types) {
37+
$path = $this->lfm->dir($this->helper->getRootFolder($type));
38+
39+
return (object) [
40+
'name' => trans('laravel-filemanager::lfm.title-' . $type),
41+
'url' => $path->path('working_dir'),
42+
'children' => $path->folders(),
43+
'has_next' => ! ($type == end($folder_types)),
44+
];
45+
}, $folder_types),
46+
])
47+
->with('items', $items);
48+
}
49+
50+
public function domove()
51+
{
52+
$target = $this->helper->input('goToFolder');
53+
$items = $this->helper->input('items');
54+
55+
foreach ($items as $item ) {
56+
$old_file = $this->lfm->pretty($item);
57+
$is_directory = $old_file->isDirectory();
58+
59+
if ($old_file->hasThumb()) {
60+
$new_file = $this->lfm->setName($item)->thumb()->dir($target);
61+
if ($is_directory) {
62+
event(new FolderIsMoving($old_file->path(), $new_file->path()));
63+
} else {
64+
event(new FileIsMoving($old_file->path(), $new_file->path()));
65+
}
66+
$this->lfm->setName($item)->thumb()->move($new_file);
67+
}
68+
$new_file = $this->lfm->setName($item)->dir($target);
69+
$this->lfm->setName($item)->move($new_file);
70+
if ($is_directory) {
71+
event(new FolderWasMoving($old_file->path(), $new_file->path()));
72+
} else {
73+
event(new FileWasMoving($old_file->path(), $new_file->path()));
74+
}
75+
};
76+
77+
return parent::$success_response;
78+
}
2279
}

src/controllers/ItemsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace UniSharp\LaravelFilemanager\controllers;
3+
namespace UniSharp\LaravelFilemanager\Controllers;
44

55
use UniSharp\LaravelFilemanager\Events\FileIsMoving;
66
use UniSharp\LaravelFilemanager\Events\FileWasMoving;

0 commit comments

Comments
 (0)