/** * Delete's the specified inquiry. * * @param int|string $id * * @return \Illuminate\Http\RedirectResponse */ public function destroy($id) { $inquiry = $this->inquiry->findOrFail($id); $this->authorize('inquiries.destroy', [$inquiry]); if ($inquiry->delete()) { flash()->success('Success!', 'Successfully deleted request.'); return redirect()->route('inquiries.index'); } flash()->error('Error!', 'There was an issue deleting this request. Please try again.'); return redirect()->route('inquiries.show', [$id]); }
/** * Deletes the specified comment. * * @param int|string $inquiryId * @param int|string $commentId * * @return \Illuminate\Http\RedirectResponse */ public function destroy($inquiryId, $commentId) { $inquiry = $this->inquiry->findOrFail($inquiryId); $comment = $inquiry->comments()->findOrFail($commentId); $this->authorize('comments.destroy', [$comment]); $inquiry->comments()->detach($comment); if ($comment->delete()) { flash()->success('Success!', 'Successfully deleted comment.'); return redirect()->route('inquiries.show', [$inquiryId]); } flash()->error('Error!', 'There was an issue deleting this comment. Please try again.'); return redirect()->route('inquiries.show', [$inquiryId]); }