dimanche 4 décembre 2016

Laravel / Eloquent : hasManyThrough SELECT

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?



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

Aucun commentaire:

Enregistrer un commentaire