public function getAvaiableUserDetailsFromOrders($selectedColumns) { try { $result = Order::join('users', function ($join) { $join->on('orders.by_user_id', '=', 'users.id'); })->join('plans', 'orders.plan_id', '=', 'plans.plan_id')->select($selectedColumns)->get(); return $result; } catch (QueryException $e) { echo $e; } }