Never mind. I just ended-up walking up the chain. Not sure why I didnt do that in the first place?????
so to get the slug I just needed:
$this->productType->shopCategory->slug
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So I have been trying to figure this out for a while and I just kind find the right relationship, or am using it wrong. Basically I am trying to get the "Grandparent" relationship from the child. Right now I have 3 tables:
merchandises
-id
-product_type_id;
-name;
-description;
-slug;
product_types
-id
-shop_category_id;
-name;
-slug;
shop_categories
-id
-name;
-slug;
So on the Merchidese model I want to be able to get the shop_category slug. I thought the relationship would be
public function shopCategory()
{
return $this->hasOneThrough(ShopCategory::class, ProductType::class);
}
but that assumes product_types has a merchandise_id which it doesnt.
Merchandise HasOne ProuductType that HasOne ShopCategory. So how do I get the ShopCategory from the Merchandise??
Please or to participate in this conversation.