HI This is my first project in Laravel 5.1. I am stuck in a laravel many to many relation please help I have a tables like
news
id | title | content
categories
id | title | cat_type
and the pivot table
category_news
id | category_id | news_id
and the models
 class News extends Model
{
   public function categories()
    {
        return $this->belongsToMany('App\Category');
    }
}
 class Category extends Model
{
   public function news() {
    return $this->belongsToMany('App\News');
  } 
}
how do i get all the news of cat_type=1 with it s related categories
please help
I tried
$news = News::whereHas('categories',
           function($query){    
              $query->where('cat_type','2');    
            })
            ->where('publish','1')
            ->orderBy('created_at', 'desc')
            ->take(5)
            ->get();//latest news
it gives a news but not related category please help thank you