F
Filament14mo ago
brahim

category infolist

i got id category in infolist but i want name of category
No description
No description
29 Replies
Resonance
Resonance14mo ago
TextEntry::make('category_name') or whatever the name of your column that stores the category name
brahim
brahimOP14mo ago
but there is a relation when i do this its give me empty public function catogories() { return $this->hasManyDeep(Category::class, [OrderItem::class, Product::class, SubCategory::class], ['order_id', 'sub_category_id', 'category_id', 'id']); } i got names with textcolumn but in infolist its empty when i do catogories.name
einnlleinhatt_
einnlleinhatt_14mo ago
Have you try this ?
Components\TextEntry::make('category.name')
Components\TextEntry::make('category.name')
brahim
brahimOP14mo ago
not working
einnlleinhatt_
einnlleinhatt_14mo ago
Not sure, first time seeing has many deep Show is your infolist code.
brahim
brahimOP14mo ago
RepeatableEntry::make('orderItems') ->schema([ TextEntry::make('category_id'), TextEntry::make('sub_category_id'), TextEntry::make('product_id'), TextEntry::make('customization_id') ->columnSpan(2), ]) ->columns(3) i have category id but i need name of category
brahim
brahimOP14mo ago
No description
einnlleinhatt_
einnlleinhatt_14mo ago
Try categories.category.name
brahim
brahimOP14mo ago
No description
einnlleinhatt_
einnlleinhatt_14mo ago
I got no more idea 🫠
Resonance
Resonance14mo ago
use a dot notation, it seems that it is a relationship TextEntry::make('category_id.name') if the column named 'name'
brahim
brahimOP14mo ago
i tried but its empty
brahim
brahimOP14mo ago
No description
Resonance
Resonance14mo ago
make sure relationship is defined, or provide more info about your columns
Rupadana
Rupadana14mo ago
Does orderItem have many categories?
brahim
brahimOP14mo ago
no but i have Order->OrderItem->Product->Subcategory->Category do i need to relation between categorie and orderitem i have in order model public function catogories() { return $this->hasManyDeep(Category::class, [OrderItem::class, Product::class, SubCategory::class], ['order_id', 'sub_category_id', 'category_id', 'id']); } OrderItem wih Order : order_id
brahim
brahimOP14mo ago
No description
brahim
brahimOP14mo ago
RepeatableEntry::make('orderItems') ->schema([ TextEntry::make('category_id.name'), TextEntry::make('sub_category_id'), TextEntry::make('product_id'), for more informations
Rupadana
Rupadana14mo ago
all your need is already in documentation
Rupadana
Rupadana14mo ago
the concept is same
sadiqgoni13
sadiqgoni1314mo ago
Hello this was exactly what i experienced yesterday i still did not find the solution , have you ?
AliBabba420
AliBabba42014mo ago
Give relationship properly first if you define category function then it should access by using category_id.name only if you not get that then the relationship is not define properly I also face some issue and a set the function name wrongly
brahim
brahimOP14mo ago
this is relations that i have in order model public function orderItems() { return $this->hasMany(OrderItem::class); } public function catogories() { return $this->hasManyDeep(Category::class, [OrderItem::class, Product::class, SubCategory::class], ['order_id', 'sub_category_id', 'category_id', 'id']); } public function subcategories() { return $this->hasManyDeep(SubCategory::class, [OrderItem::class, Product::class], ['order_id', 'sub_category_id', 'id']); }

public function customizations() { return $this->hasManyDeep(Customization::class, [OrderItem::class ,Product::class, CustomizationProduct::class], ['order_id', 'id', 'product_id', 'id']); } when i use catogorie relation its working on columntext but i use its in RepeatableEntry::make('orderItems') not working
brahim
brahimOP14mo ago
No description
brahim
brahimOP14mo ago
look in the image its working on textcolunm but when i do same in RepeatableEntry not work
Rupadana
Rupadana14mo ago
It looks like you use a column name instead of relation name
brahim
brahimOP14mo ago
Yes
Rupadana
Rupadana14mo ago
Thats the problem

Did you find this page helpful?