I have a product model, inventory model, and user_inventory model and the user_inventory model has sale_price. I want to receive the product inventory which has smallest user inventory sale price and also the user_inventory
the output show be like:
products:{
id
inventories:{
id
product_id
user_inventories:{
id
inventory_id
sale_price:smallest value
}
}
},.....
it may help to define a new model relation in inventory model like this:
so it may return lowest sale_price of user_inventory for each inventory
for example: