Tuesday, April 17, 2018

Laravel – Retrieve result from relation - development

Laravel – Retrieve result from relation

I need some help from anyone to resolve this problem.
I have create a small project in Laravel.
I have two tables: cables and associations.

cables
id | cable | price

1 | OMDS001 | 144.50
2 | OMDS001-MC | 152.70
3 | OMDS001-NC | 149.00
4 | AR-T4CR | 167.90


associations
cable_id | cable_associated_id

1 | 2
1 | 3


The relationship is: one cable hasMany associaton
I have to set the final sale price.

The constraint is that if the cables are associated with each other (as 1, 2 and 3), the final selling price of each must be the highest.

In this specific case the final sales prices must be:

1 | OMDS001 | 152.70
2 | OMDS001-MC | 152.70
3 | OMDS001-NC | 152.70
4 | AR-T4CR | 167.90

The value must be visual only and must not be entered in the database.
Thanks for eventually help.



from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-retrieve-result-from-relation/
via Lzo Media

No comments:

Post a Comment