Php 如何获取Laravel会话::Flash中Flash消息的总数
我想知道会话闪存消息的总数 我已经查看了Php 如何获取Laravel会话::Flash中Flash消息的总数,php,laravel,Php,Laravel,我想知道会话闪存消息的总数 我已经查看了illumb\Session\Store.php以查看是否存在某种count()方法。但我没有看到 这可能吗 我这样做是因为我想创建一个带有徽章的“通知区域”,以显示会话中有多少条消息 <li class="header">You have {{SESSION_COUNT_HERE}} notifications</li> 输出显示 #session: Illuminate\Session\Store {#270 ▼
illumb\Session\Store.php
以查看是否存在某种count()
方法。但我没有看到
这可能吗
我这样做是因为我想创建一个带有徽章的“通知区域”,以显示会话中有多少条消息
<li class="header">You have {{SESSION_COUNT_HERE}} notifications</li>
输出显示
#session: Illuminate\Session\Store {#270 ▼
#id: ""
#name: "laravel_session"
#attributes: array:7 [▼
"_token" => ""
"_previous" => array:1 [▼
"url" => "http://mysite.dev"
]
"_flash" => array:2 [▼
"old" => []
"new" => array:6 [▼
0 => "success"
1 => "success"
2 => "success"
3 => "warning"
4 => "danger"
5 => "info"
]
]
"success" => "This is a success 3 test"
"warning" => "This is a warning test"
"danger" => "This is a danger test"
"info" => "This is a info test"
]
虽然键属性“new”显示正确的计数,但实际上只有最后一条成功消息
Session::flash('success', 'This is a success 1 test');
Session::flash('success', 'This is a success 2 test');
Session::flash('success', 'This is a success 3 test');
Session::flash('warning', 'This is a warning test');
Session::flash('danger', 'This is a danger test');
Session::flash('info', 'This is a info test');
dd(session());
#session: Illuminate\Session\Store {#270 ▼
#id: ""
#name: "laravel_session"
#attributes: array:7 [▼
"_token" => ""
"_previous" => array:1 [▼
"url" => "http://mysite.dev"
]
"_flash" => array:2 [▼
"old" => []
"new" => array:6 [▼
0 => "success"
1 => "success"
2 => "success"
3 => "warning"
4 => "danger"
5 => "info"
]
]
"success" => "This is a success 3 test"
"warning" => "This is a warning test"
"danger" => "This is a danger test"
"info" => "This is a info test"
]