jeudi 8 novembre 2018

How do i join two queries and then paginate

    $data = Category::join('articles', function ($join) {
       $join->on('categories.id', 'articles.category_id')
        ->where('categories.type', 'news')
        ->where('articles.status', '1');
    })->get()->sortByDesc('updated_at')->paginate(5);

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire