Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Events/FolderWasRenamed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Unisharp\Laravelfilemanager\Events;

class FolderWasRenamed
{
private $path;

public function __construct($old_path, $new_path)
{
$this->old_path = $old_path;
$this->new_path = $new_path;
}

/**
* @return string
*/
public function old_path()
{
return $this->old_path;
}

public function new_path()
{
return $this->new_path;
}

}
6 changes: 4 additions & 2 deletions src/controllers/RenameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Str;
use Lang;
use Unisharp\Laravelfilemanager\Events\ImageWasRenamed;
use Unisharp\Laravelfilemanager\Events\FolderWasRenamed;

/**
* Class RenameController
Expand Down Expand Up @@ -39,10 +40,9 @@ public function getRename()
return Lang::get('laravel-filemanager::lfm.error-rename');
}

Event::fire(new ImageWasRenamed($old_file, $new_file));

if (File::isDirectory($old_file)) {
File::move($old_file, $new_file);
Event::fire(new FolderWasRenamed($old_file, $new_file));
return 'OK';
}

Expand All @@ -52,6 +52,8 @@ public function getRename()
File::move($thumb_path . $old_name, $thumb_path . $new_name);
}

Event::fire(new ImageWasRenamed($old_file, $new_file));

return 'OK';
}
}