vendredi 20 août 2021

Error trying to get property 'users' of non-object

I have a problem, i am doing a shift history of the user logged in the application.

   @foreach($eventos as $evento)
                        if($evento->solicitud->users->id == (Auth::user()->id))
                            <div class="item-timeline">
                                <div class="t-meta-date">
                                    <p class=""></p>
                                </div>
                                <div class="t-dot">
                                </div>
                                <div class="t-text">
                                    <p></p>
                                    <p></p>
                                </div>
                            </div>
                     @endif
                        @endforeach

I get all shifts with:

 $eventos = Eventos::All();

and then filter with if condition

But it shows me error Trying to get property 'users' of non-object

dd capture: https://i.imgur.com/WUVOaO6.png

data base: https://i.imgur.com/J5YSvxQ.png

i need to get the User_id from the solicitudes table.

the relation is: Eventos table-> solicitud_id with the ID column of the Solicitudes table



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

Aucun commentaire:

Enregistrer un commentaire