4

My question is little hard to explain but I will try to elaborate it cleanly. I have a StoreController which includes single show($id) function used to display single page product data. This function has one return statement which is ( return View::make('store.show')->with('product', product::find($id)); ) BUT I have one other view i.e store.category where I want to display category wise results for products , Now how to accomplish this ? One method which I have in mind is to use this show function and return this ( return View::make('store.category'); ) BUT there already is a return in SHOW function !

PS : Using Resource Controller and Laravel 5.2 , if any other thing is needed just mention in comments I will add it asap!

public function show($id) {
        return View::make('store.show')->with('product', product::find($id));
}

1 Answers1

5

You can't do this. What you can do is to use Blade view system to include as many views as you want. Good view inheritance is what you usually want.

If you need to include store.category view to this particular page, you could do something like this:

public function show($id) {
        return View::make('store.show')->with('product', product::find($id))->with('showStore', true);
}

And in a view:

@if(showStore)
@include('store.category')
@endif
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279