How can i display products in order table & add product filter in order page?
We have 3 tables here
order-> orderLineItem -> product
How can i connect relation between order & product ?
One order can have multiple products
10 Replies
You gonna have to describe much better what you trying to accomplish, and what you already got. We can't even tell if its related do Filamentphp or not...
I want to display products in my order table in filamentphp but order is not directly connected with product.
Order is connected with orderLineItem & orderLineItem have product_id and i want to display name so i need to again connect with product so how can i display that in order table ?
I want to put product filter in order page so how can i add that?
I want to display products in my order table in filamentphp but order is not directly connected with product.
Order is connected with orderLineItem & orderLineItem have product_id and i want to display name so i need to again connect with product so how can i display that in order table ?
I want to put product filter in order page so how can i add that?
How are they connected? How would you fetch them with Laravel only?
If I understand correct maybe this is what you are searching for?
In App\Models\Order
What's code for display product in table & filter in Resource file?
I think you can then do something like this in the table of orders:
TextColumn::make('products.name')
->listWithLineBreaks()
->bulleted()
Its not working and give error like this
Do you got proper idea about table connection?
It's like :
Order is connected with orderLineItem (orderLineItem have order_id & product_id column) and i want to display product name so i need to again connect with product
![No description](https://cdn.answeroverflow.com/1261202660921704469/image.png)
Sounds like Order hasMany LineItems and LineItem belongsTo Product and Order. So you can try:
Make sure to lazy load your data:
Where i need to put lazy loading code?
Inside the
->table()
method of your resource. Code is untested and might need some adjustment