3 years ago

How do i join two queries and then paginate

Posted 3 years ago by KHAN


I have 2 variables both querying the same model. I want to now merge these 2 separate datasets into a variable called $events and then paginate on it.

        $archivedEvents = EventModel::where('start_date', '<', Carbon::now())->where('is_private', '=', false);
        $privateEvents = EventModel::whereIn('id', $userEventIDs)->where('is_private', '=', true);
        // TODO: Merge
        $events->paginate(5, ['*'], $eventsPage, null);

How can i do this?

Note the paginate needs to look exactly like above ( use same variables), i have tried manually creating a new paginator but not sure how it resembles ->paginate() function.

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