{"_id":"5772979adceb570e003a907e","parentDoc":null,"version":{"_id":"576ebdb79c84a31900958abd","project":"576ebdb79c84a31900958aba","__v":10,"createdAt":"2016-06-25T17:21:59.854Z","releaseDate":"2016-06-25T17:21:59.854Z","categories":["576ebdb79c84a31900958abe","576ebfc59c84a31900958ac4","576ec32f52f96619007cfb9a","576ec7b7560eef0e00cd3096","576ed4249c84a31900958add","576ed429560eef0e00cd30a3","576ed43a52f96619007cfbb5","576ed44d5a8c72170082b794","577212f20da40019004f0816","57725c7e0a6d610e00de9e4c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.3.0","version":"3.3"},"user":"576ebd239c84a31900958ab9","project":"576ebdb79c84a31900958aba","__v":5,"category":{"_id":"576ec7b7560eef0e00cd3096","version":"576ebdb79c84a31900958abd","__v":0,"project":"576ebdb79c84a31900958aba","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-25T18:04:39.266Z","from_sync":false,"order":3,"slug":"deployment","title":"Basics"},"githubsync":"","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-06-28T15:28:26.057Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"Messages Component bring a unified notification support for Orchestra Platform.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Adding Messages\"\n}\n[/block]\nAdding a message is as easy as following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nuse Orchestra\\\\Support\\\\Facades\\\\Messages;\\n\\nMessages::add('success', 'A successful message');\\n\\n# You can also chain multiple messages.\\n\\nMessages::add('success', 'A successful message')\\n  ->add('error', 'Some error');\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Appending Messages to Current Request\"\n}\n[/block]\nThere might be situation where you need to extend a message to the current response instead of the following request. You can do this with:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nuse Orchestra\\\\Messages\\\\MessageBag;\\nuse Orchestra\\\\Support\\\\Facades\\\\Messages;\\n\\nMessages::extend(function (MessageBag $message) {\\n  $message->add('info', 'Read-only mode');\\n});\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Displaying Messages\"\n}\n[/block]\nBy default Orchestra Platform includes `orchestra/foundation::components.messages` view to render the generated flash messages. However you can create your own solution such as:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n$message = Messages::retrieve();\\n\\nif ($message instanceof Orchestra\\\\Messages\\\\MessageBag) {\\n\\t$message->setFormat('<div class=\\\"alert alert-:key\\\">:message</div>');\\n\\n\\tforeach (['error', 'info', 'success'] as $key) {\\n\\t\\tif ($message->has($key)) {\\n\\t\\t\\techo implode('', $message->get($key));\\n\\t\\t}\\n\\t}\\n}\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]","excerpt":"Messages Component","slug":"flash-notification","type":"basic","title":"Flash Notification"}

Flash Notification

Messages Component

Messages Component bring a unified notification support for Orchestra Platform. [block:api-header] { "type": "basic", "title": "Adding Messages" } [/block] Adding a message is as easy as following: [block:code] { "codes": [ { "code": "<?php\n\nuse Orchestra\\Support\\Facades\\Messages;\n\nMessages::add('success', 'A successful message');\n\n# You can also chain multiple messages.\n\nMessages::add('success', 'A successful message')\n ->add('error', 'Some error');", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "Appending Messages to Current Request" } [/block] There might be situation where you need to extend a message to the current response instead of the following request. You can do this with: [block:code] { "codes": [ { "code": "<?php\n\nuse Orchestra\\Messages\\MessageBag;\nuse Orchestra\\Support\\Facades\\Messages;\n\nMessages::extend(function (MessageBag $message) {\n $message->add('info', 'Read-only mode');\n});", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "Displaying Messages" } [/block] By default Orchestra Platform includes `orchestra/foundation::components.messages` view to render the generated flash messages. However you can create your own solution such as: [block:code] { "codes": [ { "code": "<?php\n\n$message = Messages::retrieve();\n\nif ($message instanceof Orchestra\\Messages\\MessageBag) {\n\t$message->setFormat('<div class=\"alert alert-:key\">:message</div>');\n\n\tforeach (['error', 'info', 'success'] as $key) {\n\t\tif ($message->has($key)) {\n\t\t\techo implode('', $message->get($key));\n\t\t}\n\t}\n}", "language": "php" } ] } [/block]