Laravel function call question
Posted: Tue Aug 18, 2015 3:35 pm
I am building a small demo ecommerce website and basiclly have managed to build a small prototype. now i have main page, Here https://github.com/gautamz07/laravel-ec ... .blade.php , On the main page there are 4 products loaded (the latest products). now when you click on the inidivisual products , it takes you to the indivisual backpages of the product (https://github.com/gautamz07/laravel-ec ... .blade.php) .
You must be wondering how does clicking on the indivisual links take you to its backpages , if you have a closer look at the code on index.blade.php the href of each a tag looks like so:
.
have a look at the store controller here https://github.com/gautamz07/laravel-ec ... er.php#L17
did you notice the following method:
I think the view part in the controller is calling getView() in the storeController, this is amusing to me, as how does laravel or php know how to map view (in the link ) to getView($id) function ??
Thank you.
You must be wondering how does clicking on the indivisual links take you to its backpages , if you have a closer look at the code on index.blade.php the href of each a tag looks like so:
Code: Select all
<a href="store/view/{{ $product->id }}">have a look at the store controller here https://github.com/gautamz07/laravel-ec ... er.php#L17
did you notice the following method:
Code: Select all
public function getView($id) {
return View::make('store.view')->with('product' , Product::find($id));
}
Thank you.