I am playing with Laravel5.
I have two model User & Items. And relation is User hasMany Items
I want to retrieve selected column from Items.
For example hasMany return [] (empty array of items)
User::with(['items'=>function($q){
$q->select(['name','desc']);
}])
->find($id);
Above example return empty items array but if i change this relation to User hasOne Item then it works.
hasOne return only two column name & desc
User::with(['item'=>function($q){
$q->select(['name','desc']);
}])
->find($id);
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1F2l4Iv
via IFTTT
Aucun commentaire:
Enregistrer un commentaire