I want to load my users with a hasManyThrough
call and only get the email of the users. Now it returns my all values (id, name, etc.). Using the $hidden
variable in Users
is 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, but
HasManyThrough` 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