1 year ago

multi level relationships dbquery

Posted 1 year ago by Atef95

Hey guys , I've an issue that I couldn't access to multi level relationships in dbquery

I have already this query that works properly the idea is I have one table called " car_maintenance" that is related to " cars" Table

car hasMany car_maintenance

I want to display sum of a field inside " car_maintenance" table called " total_price" for every car_id

                                        $getBookingDays= DB::table('bookings')
                                        DB::raw('sum(DATEDIFF(,bookings.from)) as bookingDays'),
                                        DB::raw('365-sum(DATEDIFF(,bookings.from)) as parkingStay'),
                                        DB::raw('cars.daily_price*sum(DATEDIFF(,bookings.from)) as gains'),

whenever I add the line below , I get a double value for "booking days "


I hope you're getting what I mean..

thank you in advance

Please sign in or create an account to participate in this conversation.