mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 17:57:09 +00:00
Various code cleanup.
This commit is contained in:
@@ -26,15 +26,13 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Requests\AttachmentFormRequest;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response as LaravelResponse;
|
||||
use Preferences;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class AttachmentController.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it's 13.
|
||||
*/
|
||||
class AttachmentController extends Controller
|
||||
{
|
||||
@@ -63,7 +61,7 @@ class AttachmentController extends Controller
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function delete(Attachment $attachment)
|
||||
{
|
||||
@@ -88,7 +86,7 @@ class AttachmentController extends Controller
|
||||
$this->repository->destroy($attachment);
|
||||
|
||||
$request->session()->flash('success', (string)trans('firefly.attachment_deleted', ['name' => $name]));
|
||||
Preferences::mark();
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUri('attachments.delete.uri'));
|
||||
}
|
||||
@@ -128,7 +126,7 @@ class AttachmentController extends Controller
|
||||
* @param Request $request
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return View
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function edit(Request $request, Attachment $attachment)
|
||||
{
|
||||
@@ -169,35 +167,36 @@ class AttachmentController extends Controller
|
||||
* @param AttachmentFormRequest $request
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function update(AttachmentFormRequest $request, Attachment $attachment)
|
||||
public function update(AttachmentFormRequest $request, Attachment $attachment): RedirectResponse
|
||||
{
|
||||
$data = $request->getAttachmentData();
|
||||
$this->repository->update($attachment, $data);
|
||||
|
||||
$request->session()->flash('success', (string)trans('firefly.attachment_updated', ['name' => $attachment->filename]));
|
||||
Preferences::mark();
|
||||
app('preferences')->mark();
|
||||
|
||||
$redirect = redirect($this->getPreviousUri('attachments.edit.uri'));
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('attachments.edit.fromUpdate', true);
|
||||
|
||||
return redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]);
|
||||
$redirect = redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]);
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
// redirect to previous URL.
|
||||
return redirect($this->getPreviousUri('attachments.edit.uri'));
|
||||
return $redirect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return LaravelResponse
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function view(Attachment $attachment)
|
||||
public function view(Attachment $attachment): LaravelResponse
|
||||
{
|
||||
if ($this->repository->exists($attachment)) {
|
||||
$content = $this->repository->getContent($attachment);
|
||||
|
Reference in New Issue
Block a user