When i write this code my relationship is not working. How can i write this part of code so that i can access to $article->translations()
. Any suggestion?
$date_number = strval(date('m', strtotime($month)));
$articles = DB::table('articles')->whereRaw('MONTH(created_at) ='.$date_number)->where('approved',1)->get();
foreach($articles as $article){
$article->trans = $article->translations()->whereHas('language',function($query) use($current_language_id){
$query->where('id','=',$current_language_id);
})->first();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire