mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-29 03:10:51 +00:00
V1.1
User Authentication - Login to user account - Register new user account - Reset user password Functionality - Added locations to menu - Added trash for deleted folders & files - Restore files or folders from trash - Empty trash function - Favourites folders - List of 5 latest uploads - Profile settings page - Storage info and upload limits Design - Night Mode - Navigation sidebar - Quick action buttons in mobile version - Improved mobile UX - Other small design improvements Settings - Enable/Disable user account registration - Set storage limitation - Set storage capacity for all users
This commit is contained in:
@@ -65,7 +65,7 @@ class FileManagerFile extends Model
|
||||
*/
|
||||
public function getThumbnailAttribute()
|
||||
{
|
||||
return $this->attributes['thumbnail'] ? route('file', ['name' => $this->attributes['thumbnail']]) : null;
|
||||
return $this->attributes['thumbnail'] ? route('thumbnail', ['name' => $this->attributes['thumbnail']]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Scout\Searchable;
|
||||
use RecursiveArrayIterator;
|
||||
@@ -120,7 +121,7 @@ class FileManagerFolder extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all files
|
||||
* Get all trashed files
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@@ -140,9 +141,14 @@ class FileManagerFolder extends Model
|
||||
return $this->children()->with('folders');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all trashed folders
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function trashed_folders()
|
||||
{
|
||||
return $this->children()->with('folders')->withTrashed()->select(['parent_id', 'unique_id']);
|
||||
return $this->children()->with('trashed_folders')->withTrashed()->select(['parent_id', 'unique_id', 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,6 +161,16 @@ class FileManagerFolder extends Model
|
||||
return $this->hasMany('App\FileManagerFolder', 'parent_id', 'unique_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get trashed childrens
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function trashed_children()
|
||||
{
|
||||
return $this->hasMany('App\FileManagerFolder', 'parent_id', 'unique_id')->withTrashed();
|
||||
}
|
||||
|
||||
// Delete all folder childrens
|
||||
public static function boot()
|
||||
{
|
||||
@@ -169,9 +185,15 @@ class FileManagerFolder extends Model
|
||||
|
||||
static::restoring(function ($item) {
|
||||
|
||||
$item->children()->each(function($folder) {
|
||||
// Restore children folders
|
||||
$item->trashed_children()->each(function($folder) {
|
||||
$folder->restore();
|
||||
});
|
||||
|
||||
// Restore children files
|
||||
$item->trashed_files()->each(function($files) {
|
||||
$files->restore();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,14 +334,20 @@ class FileManagerController extends Controller
|
||||
if ($request->type === 'folder') {
|
||||
|
||||
// Get folder
|
||||
$item = FileManagerFolder::withTrashed()->where('user_id', $user_id)->where('unique_id', $request->unique_id)->first();
|
||||
$item = FileManagerFolder::onlyTrashed()->where('user_id', $user_id)->where('unique_id', $request->unique_id)->first();
|
||||
|
||||
// Restore item to home directory
|
||||
if ($request->has('to_home') && $request->to_home) {
|
||||
$item->parent_id = 0;
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
||||
// Get file
|
||||
if ($request->type === 'file' || $request->type === 'image') {
|
||||
|
||||
// Get item
|
||||
$item = FileManagerFile::withTrashed()->where('user_id', $user_id)->where('unique_id', $request->unique_id)->first();
|
||||
$item = FileManagerFile::onlyTrashed()->where('user_id', $user_id)->where('unique_id', $request->unique_id)->first();
|
||||
|
||||
// Restore item to home directory
|
||||
if ($request->has('to_home') && $request->to_home) {
|
||||
@@ -534,9 +540,9 @@ class FileManagerController extends Controller
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get file record
|
||||
$file = FileManagerFile::withTrashed()->where('user_id', $user_id)
|
||||
$file = FileManagerFile::withTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->where('basename', $filename)
|
||||
->orWhere('thumbnail', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Get file path
|
||||
@@ -558,6 +564,39 @@ class FileManagerController extends Controller
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image thumbnail
|
||||
*
|
||||
* @param $filename
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_thumbnail($filename)
|
||||
{
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
// Get file record
|
||||
$file = FileManagerFile::withTrashed()
|
||||
->where('user_id', $user_id)
|
||||
->where('thumbnail', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
// Get file path
|
||||
$path = storage_path() . '/app/file-manager/' . $file->getOriginal('thumbnail');
|
||||
|
||||
// Check if file exist
|
||||
if (!File::exists($path)) abort(404);
|
||||
|
||||
$file = File::get($path);
|
||||
$type = File::mimeType($path);
|
||||
|
||||
// Create response
|
||||
$response = Response::make($file, 200);
|
||||
$response->header("Content-Type", $type);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unique id
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user