mardi 2 avril 2019

Many to Many Relation - Access column values

I have a User model (id, first_name, last_name) and a Like model (id, to_user_id, isLiked), having a many to many relation.

I want to extract all the ids of a Like by a user, namely:

1) $user->likes It gives me all the Like model instances of the user, perfect!

2) But now I want only to extract the "id" from the instances. Doing something like this does not work: $user->likes->id

Can you help me find the proper way?

Thanks a mil! I've been struggling for hours now already...



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

Aucun commentaire:

Enregistrer un commentaire