I'm facing a really strange issue in a hasMany
relationship,
It was not returning me anything so I started digging to try to find something
so now I have this code
echo $item->id ."<br />"; var_dump($item->menuMenuCategories()->getParent()->getKey()); echo "<br>"; var_dump($item->menuMenuCategories()->getParent()->getKeyName());
echo "
";$query = $item->menuMenuCategories()->getBaseQuery()->toSql(); echo $query ."<br />";
and the result is this:
4 string(1) "4"
string(2) "id"
select * from
GS_menu_menu_categories
whereGS_menu_menu_categories
.deleted_at
is null andGS_menu_menu_categories
.item_id
= ?select * from
GS_menu_menu_categories
whereGS_menu_menu_categories
.deleted_at
is null andGS_menu_menu_categories
.item_id
= ?
Can you see the item_id = ? ??
That why it is not returning me anything..
My model has the relationship defined this way:
public function menuMenuCategories(){ return $this->hasMany('MenuMenuCategory','item_id'); }
Any idea on why it isn't working? I have the hasMany relationship in a thousand places and never had this problem..
Thank you