03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

File-Based CMS 322<br />

43<br />

44 return View::make("admin/layout/index", compact(<br />

45 "layouts",<br />

46 "edit",<br />

47 "delete"<br />

48 ));<br />

49 }<br />

50 }<br />

.<br />

This file should be saved as app/controllers/LayoutController.php.<br />

This is the first time we’re using Dependency Injection in our controller. Laravel is injecting our<br />

engine interface (which is the Blade wrapper) and our filesystem interface (which is the Flysystem<br />

wrapper). As usual, we assign the injected dependencies to protected properties. We also define two<br />

custom validation rules, which we’ll use when adding and editing the layout files.<br />

We’ve also defined an indexAction() method which will be used to display a list of layout files<br />

which can then be edited or deleted. For the interface to be complete, we are going to need the<br />

following files:<br />

1 <br />

2 <br />

3 <br />

4 <br />

5 Laravel 4 File-Based CMS<br />

6 <br />

10 <br />

14 <br />

15 <br />

16 @include("admin/include/navigation")<br />

17 <br />

18 <br />

19 <br />

20 @yield("content")

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

Saved successfully!

Ooh no, something went wrong!