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