public function deleteDocument(Request $request, Document $document) { // Does this document belong to the current user? if ($document->user->id != Auth::user()->id) { $request->session()->flash('error', 'Only the person who uploaded a file may delete it.'); return redirect('/login'); } $path = public_path() . '/files/user/' . $document->file; $document->delete(); File::delete($path); $request->session()->flash('success', 'Your file has been deleted.'); return redirect()->back(); }