mysql - Relation not loaded when using column constraint in find -


i have strange problem eloquent. let me give code first , explain:

$article = article::with('comment.reply')->find($id)->tojson(); 

this query supposed do. loads data articles table, loads comments comments table , replies replies table , spits out in json. everything's great.

$article = article::with('comment.reply')->find($id, array('short_title'))->tojson(); 

theoretically query should exact same thing limitation short_title being loaded articles table, right? guess again. happens short title being loaded, comments table gets queried somehow magically returns empty result , replies table ignored.

do have wrong expectations or doing wrong here? relationships relatively simple, articles->hasmany('comments') , comments->hasmany('replies').

the problem don't select keys, , needed eloquent build collection. this:

$article = article::with('comment.reply')->find($id, array('id', 'short_title'))->tojson(); 

should query loaded relations need select parent key (article_id, comment_id etc) well


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -