0
I have a Windows project, I have index.blade.php that where the header and footer part are fixed, and content and that changes. My problem is to return data from a controller to the footer, it lists the data when I am on the homepage when I change url gives me a Undefined variable error that are the variables I have on the footer.
Route
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);
}
Isn’t there any code there to explain or post? The question of the way posed is difficult to answer.
– Wallace Maxters
I’ve already put
– César Sousa
Add the view index code to help
– Ademir Mazer Jr - Nuno
Man is very confused this there, please try to explain better.
– Kayo Bruno