I'm trying to select columns from related models, but I'm not quite sure how to do it using Eloquent (I want to avoid the DB namespace).
This is what I have so far...
$users = User::with("role", "country") -> select(["first_name", "last_name", "email_address"]);
How would I go about modifying the select list so that it also includes role.title
and country.name
?
So essentially, my select list would look something like this:
-> select(["first_name", "last_name", "email_address", "role.title", "country.name"]);
Many thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire