F
Filament13mo ago
brahim

category infolist

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