Answer the question
In order to leave comments, you need to log in
How to get relations from collections in laravel?
I get a collection of users
$users = User::whereIn('id', [1, 2, 3])->get();
The User model has a many-to-many relationship with the Role model
, is it possible to get the relationship values directly from the collection, without iterating in a foreach loop?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question