无法访问 Laravel blade 循环中的 object 值

Can't access object values in Laravel blade loop

我在尝试访问 Laravel blade.

中的 object 值时遇到了奇怪的行为

我的数据如下所示:

<?php


array:11 [▼
  "Monday, 18.10.2021" => array:6 [▶
    1 => array:1 [▶
      0 => {#1532 ▶
        +"id": 252
        +"status": 1
        +"heading": "Online Event für Test #1"
        +"customer": "Test #1"
        +"event_type_id": 12
        +"slug": "event_11111"
        +"datetime": "2021-10-18 10:00:00"
        +"name": "Online Event"
        +"duration": 3
      }
    ]
    2 => array:1 [▶
      0 => {#1501 ▶
        +"id": 252
        +"status": 1
        +"heading": "Online Event für Test #1"
        +"customer": "Test #1"
        +"event_type_id": 12
        +"slug": "event_11111"
        +"datetime": "2021-10-18 10:00:00"
        +"name": "Online Event"
        +"duration": 3
      }
    ]
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Tuesday, 19.10.2021" => array:6 [▶
    1 => []
    2 => []
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Wednesday, 20.10.2021" => array:6 [▶
    1 => []
    2 => []
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Thursday, 21.10.2021" => array:6 [▶
    1 => []
    2 => []
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Friday, 22.10.2021" => array:6 [▶
    1 => array:1 [▶
      0 => {#1637 ▶
        +"id": 253
        +"status": 1
        +"heading": "Online Event für Test #2"
        +"customer": "Test #2"
        +"event_type_id": 12
        +"slug": "event_22222"
        +"datetime": "2021-10-22 14:00:00"
        +"name": "Online Event"
        +"duration": 5
      }
    ]
    2 => array:1 [▶
      0 => {#1615 ▶
        +"id": 253
        +"status": 1
        +"heading": "Online Event für Test #2"
        +"customer": "Test #2"
        +"event_type_id": 12
        +"slug": "event_22222"
        +"datetime": "2021-10-22 14:00:00"
        +"name": "Online Event"
        +"duration": 5
      }
    ]
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  "Saturday, 23.10.2021" => array:6 [▶
    1 => []
    2 => []
    3 => []
    5 => []
    6 => []
    31 => []
  ]
  ....

我的 blade 文件是这样的:

<?php

             @foreach($overview_pivot as $datetime => $users)
                <tr>
                  <td>{{ $datetime }}</td>
                  @foreach($users as $user_id => $user_events_array)
                  <td>
                    @foreach($user_events_array as $events)
                      <ul class="list-group list-group-flush" data-toggle="checklist">
                        @foreach($events as $event)

                           //Works fine
                           {{ $event  }} 

                           //Error
                           {{ $event->id  }} 
                        
                        @endforeach
                      </ul>
                    @endforeach

                  </td>
                  @endforeach
                </tr>

              @endforeach

问题:

当我尝试访问 object {{ $event }} 时一切正常,但是当我尝试回显 object 值时(例如 {{ $event-> ID }})。我收到错误消息“正在尝试获取 non-object 的 属性 'id'”。

知道我的代码有什么问题吗?

@foreach($events as $event) 是错误的。

删除最后一个@foreach