Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取Laravel会话::Flash中Flash消息的总数_Php_Laravel - Fatal编程技术网

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"
            ]