Example 6-18. Manually creating and using a message bag
$messages =['errors'=>['Something went wrong with edit 1!',],'messages'=>['Edit 2 was successful.',],];$messagebag =new\Illuminate\Support\MessageBag($messages);// Check for errors; if there are any, decorate and echoif($messagebag->has('errors')){echo'<ul id="errors">';foreach($messagebag->get('errors','<li><b>:message</b></li>')as$error){echo$error;}echo'</ul>';}