mardi 17 janvier 2017

How to use with and whereHas together?

I have this:

$comments = ArticleComments::orderBy('created_at','desc')->with('user')->with('article')->with('article.translations')->paginate(10);

But what i want is something like this:

  $comments = ArticleComments::orderBy('created_at','desc')->with('user')->with('article')->with('article.translations')->whereHas('article.translations',function($query) use($default_language_id){
        $query->where('language_id','=', $default_language_id )->first();
      })->paginate(10);

How can i get article.translations but only for default language? Right now i get all translations for all languages



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iD4N81
via IFTTT

Aucun commentaire:

Enregistrer un commentaire