/** * Updates the specified issue labels. * * @param IssueLabelRequest $request * @param int|string $id * * @return \Illuminate\Http\RedirectResponse */ public function store(IssueLabelRequest $request, $id) { $issue = $this->issue->findOrFail($id); if ($request->persist($issue)) { flash()->success('Success!', 'Successfully updated labels for this issue.'); return redirect()->route('issues.show', [$id]); } flash()->error('Error!', 'There was an issue adding labels to this issue. Please try again.'); return redirect()->route('issues.show', [$id]); }
/** * Returns a download response for the specified issue attachment. * * @param int|string $issueId * @param string $fileUuid * * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function download($issueId, $fileUuid) { $issue = $this->issue->findOrFail($issueId); $this->authorize($issue); $file = $issue->findFile($fileUuid); if ($path = $file->complete_path) { return response()->download($path); } $file->delete(); abort(404); }
/** * Re-Opens an issue. * * @param IssueOpenRequest $request * @param int|string $id * * @return \Illuminate\Http\RedirectResponse */ public function open(IssueOpenRequest $request, $id) { $issue = $this->issue->findOrFail($id); $this->authorize('issues.open', [$issue]); if ($request->persist($issue)) { flash()->success('Success!', 'Successfully re-opened ticket.'); return redirect()->back(); } flash()->error('Error!', 'There was a problem re-opening this ticket. Please try again.'); return redirect()->back(); }
/** * Deletes the specified issues comment. * * @param int|string $id * @param int|string $commentId * * @return \Illuminate\Http\RedirectResponse */ public function destroy($id, $commentId) { $issue = $this->issue->findOrFail($id); $comment = $issue->comments()->findOrFail($commentId); $this->authorize('comments.destroy', [$comment]); $issue->comments()->detach($comment); if ($comment->delete()) { flash()->success('Success!', 'Successfully deleted comment.'); return redirect()->back(); } flash()->error('Error!', 'There was a problem deleting this comment. Please try again.'); return redirect()->back(); }
/** * Returns a download response for the specified issue attachment. * * @param int|string $issueId * @param int|string $commentId * @param string $fileUuid * * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function download($issueId, $commentId, $fileUuid) { $issue = $this->issue->findOrFail($issueId); $this->authorize($issue); $comment = $issue->comments()->findOrFail($commentId); $file = $comment->findFile($fileUuid); if ($path = $file->complete_path) { return response()->download($path); } // The path doesn't exist, which means the file does // not exist. We'll delete the file to prevent // users from accessing it again. $file->delete(); abort(404); }