2 months ago

return more than attribute while grouping by from 3 tables

Posted 2 months ago by AhmedElGohary

i would like to return all reservations that were done by all employees that existing in specific branch ((daily)) so there are 3 tables : ticket_reservations , employees , branches employees 1 to mini ticket_reservations branchs 1 to mini emloyees

public function RetreiveMoneyDaily(){

    $TicketReservations = DB::table('ticket_reservations')
            ->select('ticket_reservations.created_at', DB::raw('SUM(price) as SumForToday'))
            ->join('employees', 'ticket_reservations.employee_id' , '=' , 'employees.id' )
            ->join('branches', 'employees.branch_id', '=', 'branches.id')
        return $TicketReservations;

i would like to get branches.id , ticket_reservations.price , employee.name

Thanks in Advance .

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