I want to attach the relationship when getting data from database by model in laravel. I use these code to do this. but I know there is better way to do this.
thanks for your helps.
$courses = Cource::orderBy('id' , 'desc')->take($count)->get();
foreach($courses as $cource){
$cource['image'] = $cource->image()->get();
$cource['rate'] = $cource->rate()->get();
}