Apr 4, 2016
0
Level 12
Problem with Relation Eloquent
Hi, I have little problem with a relation on OVH shared hosting (local doesn't have this problem). I want to retrieve category from an article. Relation is Article => Type => Category. My request is :
$articles = Article::with('type', 'type.category')->get();
But I have for each article :
$article->type->category = null;
My different models :
*ArticleModel*/
public function type(){
$this->belongsTo('App\Model\Type');
}
/*TypeModel*/
public function category(){
$this->belongsTo('App\Model\Category');
}
I show the query on categories table in the debugbar.
SELECT * FROM categories WHERE id IN (listOfDifferentId)
You have ideas to fix this bug?
PS : sorry for my poor english.
Please or to participate in this conversation.