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.
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
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
|
|
{
|
|
/**
|
|
* 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)
|
|
{
|
|
// get directory information
|
|
$directory = is_null($directoryId) ? new Directory() : Directory::findOrFail($directoryId);
|
|
|
|
// 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($fileType)) {
|
|
if (is_null($fileSubtype)) {
|
|
$files = $files->where('mime_type', 'LIKE', $fileType . '%');
|
|
} else {
|
|
$files = $files->where('mime_type', $fileType . '/' . $fileSubtype);
|
|
}
|
|
}
|
|
|
|
// include hidden directories?
|
|
$includeHidden = Input::get('hidden');
|
|
|
|
return view('admin.fileManager.overview', [
|
|
'directory' => $directory,
|
|
'subdirectories' => $directory->subdirectories($includeHidden),
|
|
'files' => $files->get()
|
|
]);
|
|
}
|
|
}
|