Tenho um projecto laravel, tenho o index.blade.php que em que a parte do header e footer sao fixas, e content e que muda. O meu problema e retornar dados de um controller para o footer, ele lista-me os dados quando estou na homepage quando mudo de url da-me um erro de undefined variable que sao as variaveis que tenho no footer.
Rota
Route::get('/', 'ListaDadosHomeController@lista_dados_home');
Controller
public function lista_dados_home (){
$builder = DB::table('categorias')
->select('*')
->where('activo', '=', '1');
$categorias_home = $builder->get();
// LISTA FOODIES HOME
$opinioes = DB::raw('(SELECT COUNT(*) AS id FROM posts WHERE user_id = users_social.id) as count_opinioes');
$seguidores = DB::raw('(SELECT COUNT(*) AS followed FROM seguidores WHERE followed = users_social.id) as `count_seguidores`');
$builder = DB::table('users_social')
->select('*', $opinioes, $seguidores)
->where('activo', '=', '1');
$top_foodies = $builder->limit(12)->get();
// CONTA NUMERO DE ESTABELECIMENTOS
$restaurantes = DB::table('estabelecimentos')->where('categoria', '=', 'restauracao')->count();
$cafes = DB::table('estabelecimentos')->where('categoria', '=', 'bares')->count();
$hoteis = DB::table('estabelecimentos')->where('categoria', '=', 'hotelaria')->count();
$opinioes = DB::table('posts')->count();
return view('home', ['top_foodies' => $top_foodies], ['categorias_home' => $categorias_home])->with('restaurantes', $restaurantes)->with('cafes', $cafes)->with('hoteis', $hoteis)->with('opinioes', $opinioes);
return view('index')->with('restaurantes', $restaurantes)->with('cafes', $cafes)->with('hoteis', $hoteis)->with('opinioes', $opinioes);
}