Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sawanaware's avatar

Trying to get property "id" of non pbject

          <table class="table mb-0">
            <thead class="table-light">
                <tr>
                 <th>No</th>
                 <th> Date</th>
                  <th>Time</th>
                @foreach($dashboards->dashnoardDeviceData as $device)
                  <th>{{$device->deviceDataKey->key_name}} Value</th>
                 @endforeach
                </tr>
              </thead>
              
               @php 
                  $page=1;
                  if(Request::input('page'))
                  $page=Request::input('page');
     
               @endphp
             @foreach($lists as $key => $list)
               <tbody>
                 <tr>
                   <td>{{ $page++ }}</td>
                   <td>{{ dateShow($list->created_at)}}</td>
                   <td>{{ timeShow($list->created_at) }}</td>
                    @foreach($dashboards->dashnoardDeviceData as $device)
                      <th>{{deviceData($list->id,$device->deviceDataKey->id,$dashboards->device_id)}}</th>
                   @endforeach
         
                     
                 </tr>
              @endforeach
          
          </table>
              
        </div>
0 likes
3 replies
sawanaware's avatar

It was working fine and now I am getting an error {Trying to get property of 'key_name' non-object } and above the blade file for the view

Nakov's avatar

So as the error says, either $list or $device->deviceDataKey is not an object and you are trying ->id

So make sure you understand what data it contains, it might be an array so you will need $device->deviceDataKey['id'] as an example.

webrobert's avatar

somewhere, like here $list->id you are trying to access this as an object, but its not an object. Maybe an array? $list['id'] but you have several references to id so who knows which one based on the code you shared.

Please or to participate in this conversation.