Question

This is the function that I am using in my controller

    public function homeList()
{
    //Get all the franchises
    $franchises = Franchise::all();

    //Load the view and pass the franchises
            return View::make('frontend.layouts.footer')->with('franchises', $franchises);
    } 

and I keep getting this error. I don't know how to pass it or what to put on the routes.php file

enter image description here

Was it helpful?

Solution

You should be able to do @include('frontend.layouts.footer')->with('franchises', Franchise::all()).

Update:

To avoid the model in the view, you should use a view composer, as it was stated in a previous answer.

View::composer('frontend.layouts.footer', function($view)
{
    $view->with('franchises', Franchise::all());
});

Now you have $franchises available in the view. This code you can place in routes.php or you can create a composers.php and autoload it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top