lundi 18 octobre 2021

Can't access object values in Laravel blade loop

I'm facing strange behavior when trying to access object values in Laravel blade.

My data looks like the following:

<?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 => []
  ]
  ....

And my blade file like this:

<?php

             @foreach($overview_pivot as $datetime => $users)
                <tr>
                  <td></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
                            

                           //Error
                            
                        
                        @endforeach
                      </ul>
                    @endforeach

                  </td>
                  @endforeach
                </tr>

              @endforeach

Problem:

When I try accessing the object everything works fine, but when I try to echo object values (e.g. ). I get the error "Trying to get property 'id' of non-object".

Any idea what's wrong with my code?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3aThw3H
via IFTTT

Aucun commentaire:

Enregistrer un commentaire