F
Filament9mo ago
brahim

category infolist

i got id category in infolist but i want name of category
No description
No description
29 Replies
Resonance
Resonance9mo ago
TextEntry::make('category_name') or whatever the name of your column that stores the category name
brahim
brahim9mo 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_9mo ago
Have you try this ?
Components\TextEntry::make('category.name')
Components\TextEntry::make('category.name')
brahim
brahim9mo ago
not working
einnlleinhatt_
einnlleinhatt_9mo ago
Not sure, first time seeing has many deep Show is your infolist code.
brahim
brahim9mo 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
brahim9mo ago
No description
einnlleinhatt_
einnlleinhatt_9mo ago
Try categories.category.name
brahim
brahim9mo ago
No description
einnlleinhatt_
einnlleinhatt_9mo ago
I got no more idea 🫠
Resonance
Resonance9mo ago
use a dot notation, it seems that it is a relationship TextEntry::make('category_id.name') if the column named 'name'
brahim
brahim9mo ago
i tried but its empty
brahim
brahim9mo ago
No description
Resonance
Resonance9mo ago
make sure relationship is defined, or provide more info about your columns
Rupadana
Rupadana9mo ago
Does orderItem have many categories?
brahim
brahim9mo 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
brahim9mo ago
No description
brahim
brahim9mo ago
RepeatableEntry::make('orderItems') ->schema([ TextEntry::make('category_id.name'), TextEntry::make('sub_category_id'), TextEntry::make('product_id'), for more informations
Rupadana
Rupadana9mo ago
all your need is already in documentation
Rupadana
Rupadana9mo ago
the concept is same
sadiqgoni13
sadiqgoni139mo ago
Hello this was exactly what i experienced yesterday i still did not find the solution , have you ?
AliBabba420
AliBabba4209mo 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
brahim9mo 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
brahim9mo ago
No description
brahim
brahim9mo ago
look in the image its working on textcolunm but when i do same in RepeatableEntry not work
Rupadana
Rupadana9mo ago
It looks like you use a column name instead of relation name
brahim
brahim9mo ago
Yes
Rupadana
Rupadana9mo ago
Thats the problem