mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Make sure all controllers can store attachment when creating models #2828
This commit is contained in:
@@ -190,8 +190,7 @@ class EditController extends Controller
|
|||||||
$request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
$request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
// store new attachments
|
// store new attachment(s):
|
||||||
// store attachment(s):
|
|
||||||
/** @var array $files */
|
/** @var array $files */
|
||||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||||
|
@@ -129,6 +129,15 @@ class CreateController extends Controller
|
|||||||
$request->session()->flash('success', (string) trans('firefly.stored_new_budget', ['name' => $budget->name]));
|
$request->session()->flash('success', (string) trans('firefly.stored_new_budget', ['name' => $budget->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
|
// store attachment(s):
|
||||||
|
/** @var array $files */
|
||||||
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
|
$this->attachments->saveAttachmentsForModel($budget, $files);
|
||||||
|
|
||||||
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
|
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
|
||||||
$redirect = redirect($this->getPreviousUri('budgets.create.uri'));
|
$redirect = redirect($this->getPreviousUri('budgets.create.uri'));
|
||||||
|
|
||||||
if (1 === (int) $request->get('create_another')) {
|
if (1 === (int) $request->get('create_another')) {
|
||||||
|
@@ -101,6 +101,15 @@ class CreateController extends Controller
|
|||||||
$request->session()->flash('success', (string) trans('firefly.stored_category', ['name' => $category->name]));
|
$request->session()->flash('success', (string) trans('firefly.stored_category', ['name' => $category->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
|
// store attachment(s):
|
||||||
|
/** @var array $files */
|
||||||
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
|
$this->attachments->saveAttachmentsForModel($category, $files);
|
||||||
|
|
||||||
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
|
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
|
||||||
$redirect = redirect(route('categories.index'));
|
$redirect = redirect(route('categories.index'));
|
||||||
if (1 === (int) $request->get('create_another')) {
|
if (1 === (int) $request->get('create_another')) {
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
|
@@ -451,6 +451,16 @@ class PiggyBankController extends Controller
|
|||||||
session()->flash('success', (string) trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
|
session()->flash('success', (string) trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
|
// store attachment(s):
|
||||||
|
/** @var array $files */
|
||||||
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
|
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
|
||||||
|
|
||||||
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
|
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$redirect = redirect($this->getPreviousUri('piggy-banks.create.uri'));
|
$redirect = redirect($this->getPreviousUri('piggy-banks.create.uri'));
|
||||||
|
|
||||||
if (1 === (int) $request->get('create_another')) {
|
if (1 === (int) $request->get('create_another')) {
|
||||||
|
@@ -316,6 +316,16 @@ class TagController extends Controller
|
|||||||
session()->flash('success', (string) trans('firefly.created_tag', ['tag' => $data['tag']]));
|
session()->flash('success', (string) trans('firefly.created_tag', ['tag' => $data['tag']]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
|
// store attachment(s):
|
||||||
|
/** @var array $files */
|
||||||
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
|
$this->attachments->saveAttachmentsForModel($result, $files);
|
||||||
|
|
||||||
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
|
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$redirect = redirect($this->getPreviousUri('tags.create.uri'));
|
$redirect = redirect($this->getPreviousUri('tags.create.uri'));
|
||||||
if (1 === (int) $request->get('create_another')) {
|
if (1 === (int) $request->get('create_another')) {
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
|
Reference in New Issue
Block a user