Monday, March 20, 2017

Laravel 5.4 Undefined Variable from controller to view

I recently got started with Laravel 5.4, I'm familiar with 5.3. I'm trying to pass a variable from my controller to the view and keep getting an "Undefined variable $savedStores".

public function index()
{
    //

    $stores = Store::where('id as user_id')->get();

    return view('home')->with('savedStores', $store);
}

That is my controller code.

In my view, I have

             @if(count($savedStores)>0)

              @foreach($savesStores as $savedStore)
              <p></p>

              @endforeach




              @endif



via Olabinjo Adeniran

Advertisement