i'm sure this is simple, but need help
i have products, with a foreign key of category_id and i have categories, with an id, and some have a parent_id too
In my blade template, this works no problems {{ $product->category->name }}
But how do i go about showing the parent category name ? So i have {{ $product->category->parent_id }} {{ $product->category->name }} But want to convert my parent_id into the parent name, and am confused how to something like - this is obviously wrong @if($product->category->parent_id){{ $categories[$product->category->parent_id} }}@endif / {{ $product->category->name }}
Not quite sure if it is what you want?
{{ isset($this->category->parent_id)? $categories[$product->category->parent_id] : '' }} / {{ $product->category->name }}
duh - yeah exactly, new i was being stupid.
One thing thats now puzzling me is this An example {{ $product->category->parent_id }} = 4
my categories are so
#1 1 "Pergolenxy"
#2 2 "Zelten"
#3 3 "Markisen"
#4 4 "Markilux"
#5 5 "Side Blinds"
Yet for some reason when i do this $categories[$product->category->parent_id]['name']
I get "Side Blinds" instead of "Markilux", which seems a bit bizarre
Any suggestions ?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community