FEATURE #1508: merge files and directories overview.

This commit merges list of all uploaded files and created directories into one page. It also modifies way of uploading files. Special page for uploading files was removed (because of no support for directories) and files can be uploaded only via overview.
This commit is contained in:
Michal Kváček
2016-03-13 22:50:20 +01:00
parent 069367a816
commit df3bc22954
11 changed files with 151 additions and 134 deletions
@@ -4,30 +4,46 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests;
use App\Models\Directory;
use App\Models\File;
use Illuminate\Support\Facades\Input;
class UploadedFilesOverview extends Controller
{
public function getOverview($type = null, $subtype = null)
/**
* List of all files and directories
*
* @param null $directoryId
* @param null $fileType
* @param null $fileSubtype
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getOverview($directoryId = null, $fileType = null, $fileSubtype = null)
{
$directories = [];
// get directory information
$directory = is_null($directoryId) ? new Directory() : Directory::findOrFail($directoryId);
$files = File::orderBy('updated_at', 'DESC');
// get all files in this directory
$files = File::orderBy('updated_at', 'DESC')
->where('directory_id', $directory->id);
// try to filter by given type
if (!is_null($type)) {
if (is_null($subtype))
$files = $files->where('mime_type', 'LIKE', $type.'%');
else {
$files = $files->where('mime_type', $type.'/'.$subtype);
if (!is_null($fileType)) {
if (is_null($fileSubtype)) {
$files = $files->where('mime_type', 'LIKE', $fileType . '%');
} else {
$files = $files->where('mime_type', $fileType . '/' . $fileSubtype);
}
}
$files = $files->paginate(18);
// include hidden directories?
$includeHidden = Input::get('hidden');
return view('admin.fileManager.overview', [
'direcories' => $directories,
'files' => $files
'directory' => $directory,
'subdirectories' => $directory->subdirectories($includeHidden),
'files' => $files->get()
]);
}
}