diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index de9996bf41..5458193e5d 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -272,19 +272,15 @@ class TransactionController extends Controller
// save attachments:
$att->saveAttachmentsForModel($journal);
- if ($att->getErrors()->count() > 0) {
- // todo moet beter
- Session::flash('error', '
' . join('', $att->getErrors()->get('attachments', '- :message
')) . '
');
+ // flash errors
+ if (count($att->getErrors()->get('attachments')) > 0) {
+ Session::flash('error', $att->getErrors()->get('attachments'));
}
- if ($att->getMessages()->count() > 0) {
- // todo moet beter
- Session::flash('info', '' . join('', $att->getMessages()->get('attachments', '- :message
')) . '
');
+ // flash messages
+ if (count($att->getMessages()->get('attachments')) > 0) {
+ Session::flash('info', $att->getMessages()->get('attachments'));
}
-
- // do something with the messages?
-
-
// rescan journal, UpdateJournalConnection
event(new JournalSaved($journal));
@@ -325,13 +321,20 @@ class TransactionController extends Controller
// save attachments:
$att->saveAttachmentsForModel($journal);
- if ($att->getErrors()->count() > 0) {
- // todo moet beter
- Session::flash('error', '' . join('', $att->getErrors()->get('attachments', '- :message
')) . '
');
+ // one error
+ if ($att->getErrors()->count() == 1) {
+ Session::flash('error', join('', $att->getErrors()->get('attachments')));
}
+
+ if ($att->getErrors()->count() > 1) {
+ // todo moet beter
+ Session::flash('error', '' . join('', $att->getErrors()->get('attachments', '- :message
')) . '
');
+ }
+
+
if ($att->getMessages()->count() > 0) {
// todo moet beter
- Session::flash('info', '' . join('', $att->getMessages()->get('attachments', '- :message
')) . '
');
+ Session::flash('info', '' . join('', $att->getMessages()->get('attachments', '- :message
')) . '
');
}
event(new JournalSaved($journal));
diff --git a/resources/twig/partials/flashes.twig b/resources/twig/partials/flashes.twig
index d71dd9f381..5cfc0ae4ca 100644
--- a/resources/twig/partials/flashes.twig
+++ b/resources/twig/partials/flashes.twig
@@ -6,10 +6,29 @@
{% endif %}
{% if Session.has('info') %}
+
-
Info: {{ Session.get('info')|raw }}
+
+ {% if Session.get('info') is iterable and Session.get('info')|length > 1 %}
+
{{ Session.get('info')|length }} messages:
+
+ {% for err in Session.get('info') %}
+ - {{ err }}
+ {% endfor %}
+
+ {% endif %}
+ {% if Session.get('info') is iterable and Session.get('info')|length == 1 %}
+
Message:
+ {{ Session.get('info')[0]|raw }}
+ {% endif %}
+
+ {% if Session.get('info') is not iterable %}
+
Message: {{ Session.get('info')|raw }}
+ {% endif %}
+
+
{% endif %}
{% if Session.has('warning') %}
@@ -22,6 +41,23 @@
{% if Session.has('error') %}
-
Error! {{ Session.get('error')|raw }}
+
+ {% if Session.get('error') is iterable and Session.get('error')|length > 1 %}
+
{{ Session.get('error')|length }} errors:
+
+ {% for err in Session.get('error') %}
+ - {{ err }}
+ {% endfor %}
+
+ {% endif %}
+ {% if Session.get('error') is iterable and Session.get('error')|length == 1 %}
+
Error!
+ {{ Session.get('error')[0]|raw }}
+ {% endif %}
+
+ {% if Session.get('error') is not iterable %}
+
Error! {{ Session.get('error')|raw }}
+ {% endif %}
+
{% endif %}