REFACTORING #2039 @1h: clean a little bit file manager
This commit is contained in:
@@ -21,14 +21,8 @@ class EditUploadedFile extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function getDetail($id)
|
||||
public function show(File $file)
|
||||
{
|
||||
try {
|
||||
$file = File::findOrFail($id);
|
||||
} catch (NotFoundHttpException $e) {
|
||||
return $this->fileNotFound();
|
||||
}
|
||||
|
||||
return view('admin.fileManager.edit', [
|
||||
'file' => $file,
|
||||
'extraInfo' => FileManager::getAdditionalInfo($file)
|
||||
@@ -42,18 +36,14 @@ class EditUploadedFile extends Controller
|
||||
* unchanged
|
||||
*
|
||||
* @param EditUploadedFileRequest $request
|
||||
* @param $id
|
||||
* @param File $file
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @internal param $id
|
||||
*
|
||||
*/
|
||||
public function postEdit(EditUploadedFileRequest $request, $id)
|
||||
public function update(EditUploadedFileRequest $request, File $file)
|
||||
{
|
||||
try {
|
||||
$file = File::findOrFail($id);
|
||||
} catch (NotFoundHttpException $e) {
|
||||
return $this->fileNotFound();
|
||||
}
|
||||
|
||||
// set values from form
|
||||
$file->name = $request->name;
|
||||
$file->keywords = $request->keywords;
|
||||
@@ -65,23 +55,19 @@ class EditUploadedFile extends Controller
|
||||
|
||||
// update successfull
|
||||
return redirect()
|
||||
->route('upload.detail', ['id' => $id])
|
||||
->route('upload.detail', ['file' => $file])
|
||||
->with('success', trans('admin/fileManager.successfullyChanged'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes file
|
||||
*
|
||||
* @param $id
|
||||
* @param File $file
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteFile($id)
|
||||
public function delete(File $file)
|
||||
{
|
||||
try {
|
||||
$file = File::findOrFail($id);
|
||||
} catch (NotFoundHttpException $e) {
|
||||
return $this->fileNotFound();
|
||||
}
|
||||
|
||||
$directoryId = $file->directory_id;
|
||||
$file->delete();
|
||||
|
||||
@@ -89,16 +75,4 @@ class EditUploadedFile extends Controller
|
||||
->route('upload.overview', ['id' => $directoryId])
|
||||
->with('success', trans('admin/fileManager.fileDeleted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects user to files overview
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
private function fileNotFound()
|
||||
{
|
||||
return redirect()
|
||||
->route('upload.overview')
|
||||
->with('error', trans('admin/fileManager.fileNotFound'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user