The error "variable not defined" usually occurs when a variable is not defined or initialized before it is used. In this case, it seems like the variable $pinned is not defined or initialized in the controller before it is being used in the view.
To fix this, you need to define and initialize the $pinned variable in the controller before passing it to the view. Here's an example:
// Define and initialize the $pinned variable
$pinned = News::join('newssubcategories','news.subcategory_id','=','newssubcategories.id')
->join('newscategories','newssubcategories.category_id','=','newscategories.id')
->join('users','news.reporter_id','=','users.id')
->select('news.id','news.title','news.summary','news.slug','news.image','news.date','news.created_at','newssubcategories.id as catid','news.meta_title','news.meta_description','newssubcategories.name as news_subcategory','newscategories.name as news_category',DB::raw("CONCAT(users.first_name,' ',users.last_name) AS reporter_name"))
->where('news.status',1)
->where('news.published_at','<=',now())
->Where('news.top_stories',1)
//->where('news.speciality_id',1)
->orderBy('news.date', 'DESC')
->take(6)
->get();
// Pass the $pinned variable to the view
return view('your-view', compact('pinned'));
Make sure to replace your-view with the name of your actual view file.
Also, make sure that the controller file where you define and initialize the $pinned variable is being used by the route that renders the view.