Skip to content

Commit 4bb7c17

Browse files
committed
Fiddled with storage facade a little more
Signed-off-by: snipe <[email protected]>
1 parent 5fd0f56 commit 4bb7c17

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

app/Http/Controllers/Users/UserFilesController.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,20 @@ public function destroy($userId = null, $fileId = null)
8383
$this->authorize('delete', $user);
8484
$rel_path = 'private_uploads/users';
8585

86-
if ($log = Actionlog::find($fileId)) {
87-
88-
$full_filename = $rel_path.'/'.$log->filename;
8986

90-
if (Storage::exists($rel_path.'/'.$full_filename)) {
91-
Storage::delete($rel_path.'/'.$full_filename);
92-
$log->delete();
87+
if ($log = Actionlog::find($fileId)) {
88+
$filename = $log->filename;
89+
$log->delete();
90+
91+
if (Storage::exists($rel_path.'/'.$filename)) {
92+
Storage::delete($rel_path.'/'.$filename);
9393
return redirect()->back()->with('success', trans('admin/users/message.deletefile.success'));
9494
}
95-
}
9695

97-
return redirect()->back()->with('error', trans('admin/users/general.log_does_not_exist'));
96+
}
9897

98+
// The log record doesn't exist somehow
99+
return redirect()->back()->with('success', trans('admin/users/message.deletefile.success'));
99100
}
100101

101102
return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', ['id' => $userId]));

0 commit comments

Comments
 (0)