I want to load my users with a hasManyThroughcall and only get the email of the users. Now it returns my all values (id, name, etc.). Using the $hidden variable in Usersis not a good thing because on different routes the user object should return different values.
return \App\Faculty::find(1)->get()->load(['users' =>
function(\Illuminate\Database\Eloquent\Relations\HasManyThrough $query) {
//$query->select('email');
}])->first();
Objects of ´HasManyhas a->select()function, butHasManyThrough` doesn't.
So is it possible with a simple trick or do I have to load then in an attribute and filter them?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire