From 83d6158483e5955667a4f98f05f1828c091c7bc7 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 18 Jul 2015 09:49:59 +0200 Subject: [PATCH] Basic upload working. --- .../Controllers/TransactionController.php | 25 ++++++++++++++++--- app/Providers/FireflyServiceProvider.php | 3 +++ resources/twig/partials/flashes.twig | 4 +-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 8744038427..2e2037ed34 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -6,6 +6,7 @@ use Config; use ExpandedForm; use FireflyIII\Events\JournalCreated; use FireflyIII\Events\JournalSaved; +use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Http\Requests\JournalFormRequest; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; @@ -256,21 +257,37 @@ class TransactionController extends Controller * * @return \Illuminate\Http\RedirectResponse */ - public function store(JournalFormRequest $request, JournalRepositoryInterface $repository) + public function store(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att) { $journalData = $request->getJournalData(); // if not withdrawal, unset budgetid. - if($journalData['what'] != 'withdrawal') { + if ($journalData['what'] != 'withdrawal') { $journalData['budget_id'] = 0; } - $journal = $repository->store($journalData); + $journal = $repository->store($journalData); + + // save attachments: + $att->saveAttachmentsForModel($journal); + + if ($att->getErrors()->count() > 0) { + // todo moet beter + Session::flash('error', ''); + } + if ($att->getMessages()->count() > 0) { + // todo moet beter + Session::flash('info', ''); + } + + + // do something with the messages? + // rescan journal, UpdateJournalConnection event(new JournalSaved($journal)); - // ConnectJournalToPiggyBank + if ($journal->transactionType->type == 'Transfer' && intval($request->get('piggy_bank_id')) > 0) { event(new JournalCreated($journal, intval($request->get('piggy_bank_id')))); } diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 5f3b310017..a08a908fde 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -93,6 +93,9 @@ class FireflyServiceProvider extends ServiceProvider // CSV import $this->app->bind('FireflyIII\Helpers\Csv\WizardInterface', 'FireflyIII\Helpers\Csv\Wizard'); + // attachments + $this->app->bind('FireflyIII\Helpers\Attachments\AttachmentHelperInterface', 'FireflyIII\Helpers\Attachments\AttachmentHelper'); + // make charts: // alternative is Google instead of ChartJs $this->app->bind('FireflyIII\Generator\Chart\Account\AccountChartGenerator', 'FireflyIII\Generator\Chart\Account\ChartJsAccountChartGenerator'); diff --git a/resources/twig/partials/flashes.twig b/resources/twig/partials/flashes.twig index b22d3ceb1d..d71dd9f381 100644 --- a/resources/twig/partials/flashes.twig +++ b/resources/twig/partials/flashes.twig @@ -8,7 +8,7 @@ {% if Session.has('info') %} {% endif %} @@ -22,6 +22,6 @@ {% if Session.has('error') %} {% endif %}