frontend function consolidation part 2

This commit is contained in:
Peter Papp
2021-03-16 11:53:19 +01:00
parent adbe35e8b5
commit f0e9c80572
17 changed files with 368 additions and 66 deletions

View File

@@ -218,7 +218,9 @@ function is_demo($user_id)
*/
function get_item($type, $id)
{
return ('App\\Models\\' . ucfirst($type))::find($id);
$model = strtolower($type) === 'folder' ? 'Folder' : 'File';
return ("App\\Models\\$model")::find($id);
}
/**
@@ -756,6 +758,7 @@ function get_files_for_zip($folders, $files, $path = [])
$files->push([
'name' => $file->name,
'basename' => $file->basename,
'mimetype' => $file->mimetype,
'folder_path' => implode('/', $path),
]);
});