11.08.2017 Views

codebright

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Build An App 1: Playstation Game Collection 371<br />

18 <br />

19 <br />

So we have a simple HTML5 wrapper with a few interesting lines. Let’s take a closer look at them.<br />

The first is the line which specifies which CSS stylesheet to use.<br />

1 <br />

We want to use a single global stylesheet for all of our views. By including the Twitter Bootstrap<br />

CSS within our master layout, we will be able to make use of it within all of our views that extend<br />

it. We use the asset() helper function to specify a path to our asset that is relative to the project’s<br />

public directory. This means that the path used to route our application will not interfere with the<br />

URLs to our assets.<br />

The next interesting line is the menu home link. Let’s take a closer look.<br />

1 Games Collec\<br />

2 tion<br />

Once again, we use a helper function to avoid collisions with our path based routing system. This<br />

time we use the action() function to generate an absolute URL to our framework route. Using<br />

action() in combination with the {{ echo braces }} we can create a back to home link for our<br />

application. The parameter to the action() function is a controller and action pair separated with<br />

an at @ symbol, just like the pairs we used when defining our routes.<br />

Now it’s time for the final line of the template, and the most important too! Let’s take a look.<br />

1 @yield('content')<br />

The @yield() blade template method allows us to create an injectable section within our layout.<br />

This means that templates with extend our layout will be able to inject content into this area. We<br />

use the name ‘content’ to identify this region.<br />

We can now being to create some views that will extend this layout. Let’s start with the view that<br />

will be used to list all of our games. Before we begin editing the view file itself, let’s first modify our<br />

index() action to include a little logic.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!