Make sure all controllers can store attachment when creating models #2828

This commit is contained in:
James Cole
2020-03-19 09:01:35 +01:00
parent d489244c00
commit 12e81364a0
5 changed files with 39 additions and 2 deletions

View File

@@ -101,6 +101,15 @@ class CreateController extends Controller
$request->session()->flash('success', (string) trans('firefly.stored_category', ['name' => $category->name]));
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'));
if (1 === (int) $request->get('create_another')) {
// @codeCoverageIgnoreStart