Wednesday, March 1, 2017

How to get the selected columns tables in an inner join in laravel?

This is my select query with the inner join and the values that I want to select.

$user_reservation = DB::table('users')
            ->join('reservations', 'users.id', '=', 'reservations.users_id')
            ->select('users.id', 'reservations.id as res_id')
            ->get();

I need the res_id from the $user_reservation variable to be able to filter a result. Thank you

$reserved_rooms = $rr_model->where('reservation_id', '=', $user_reservation->res_id)->get();




via jean9

Advertisement