@php
$msgs = [];
if(Session::has('message')) {
$msgs = Session::get('message');
if (!isset($msgs[0])) {
$msgs = [$msgs];
}
}
if(!isset($error)) {
$error = [];
}
if ($errors->any()) {
array_push($error, ...$errors->all());
}
foreach(['error', 'success', 'info', 'warning'] as $type) {
if (!isset($$type)) {
$$type = [];
}
if (!is_array($$type)) {
$$type = [$$type];
}
$from_session = Session::get($type, []);
if (!is_array($from_session)) {
$from_session = [$from_session];
}
if (count($from_session) > 0) {
array_push($$type, ...$from_session);
}
$msgs = array_merge(
$msgs,
array_map(
function($content) use ($type) {
return [
'type' => $type,
'content' => $content,
];
},
$$type
)
);
}
@endphp
@foreach($msgs as $msg)
@php($msg = (object)$msg)
@component('components.message', [
'type' => $msg->type,
'content' => $msg->content,
])
@endcomponent
@endforeach
@yield('content')