/**
  * @param JournalFormRequest         $request
  * @param JournalRepositoryInterface $repository
  * @param AttachmentHelperInterface  $att
  * @param TransactionJournal         $journal
  *
  * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att, TransactionJournal $journal)
 {
     $journalData = $request->getJournalData();
     $repository->update($journal, $journalData);
     // save attachments:
     $att->saveAttachmentsForModel($journal);
     // flash errors
     if (count($att->getErrors()->get('attachments')) > 0) {
         Session::flash('error', $att->getErrors()->get('attachments'));
     }
     // flash messages
     if (count($att->getMessages()->get('attachments')) > 0) {
         Session::flash('info', $att->getMessages()->get('attachments'));
     }
     event(new TransactionJournalUpdated($journal));
     // update, get events by date and sort DESC
     Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.');
     Preferences::mark();
     if (intval(Input::get('return_to_edit')) === 1) {
         // set value so edit routine will not overwrite URL:
         Session::put('transactions.edit.fromUpdate', true);
         return redirect(route('transactions.edit', [$journal->id]))->withInput(['return_to_edit' => 1]);
     }
     // redirect to previous URL.
     return redirect(Session::get('transactions.edit.url'));
 }
Esempio n. 2
0
 /**
  * @param JournalFormRequest         $request
  * @param JournalRepositoryInterface $repository
  * @param TransactionJournal         $journal
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(JournalFormRequest $request, JournalRepositoryInterface $repository, TransactionJournal $journal)
 {
     $journalData = $request->getJournalData();
     $repository->update($journal, $journalData);
     event(new JournalSaved($journal));
     // update, get events by date and sort DESC
     Session::flash('success', 'Transaction "' . e($journalData['description']) . '" updated.');
     Preferences::mark();
     if (intval(Input::get('return_to_edit')) === 1) {
         // set value so edit routine will not overwrite URL:
         Session::put('transactions.edit.fromUpdate', true);
         return Redirect::route('transactions.edit', [$journal->id])->withInput(['return_to_edit' => 1]);
     }
     // redirect to previous URL.
     return Redirect::to(Session::get('transactions.edit.url'));
 }