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.

API 130<br />

.<br />

You can optionally specify the template to be used in the creation of seeders, models and controllers.<br />

you do this by providing the –template option with the path to a Mustache template file.<br />

Unfortunately migrations do not have this option. If you find yourself using these generators often<br />

enough, and wanting to customise the way in which new class are created; you will probably want<br />

to take a look at this option (and the template files in vendor/way/generators/src/Way/Generators/Generators/templates).<br />

.<br />

You can find out more about Jeffrey Way’s Laravel 4 Generators at: https://github.com/JeffreyWay/Laravel-<br />

4-Generators.<br />

Binding Models To Routes<br />

Before we can access these; we need to add routes for them:<br />

1 Route::model("event", "Event");<br />

2<br />

3 Route::get("event", [<br />

4 "as" => "event/index",<br />

5 "uses" => "EventController@index"<br />

6 ]);<br />

7<br />

8 Route::post("event", [<br />

9 "as" => "event/store",<br />

10 "uses" => "EventController@store"<br />

11 ]);<br />

12<br />

13 Route::get("event/{event}", [<br />

14 "as" => "event/show",<br />

15 "uses" => "EventController@show"<br />

16 ]);<br />

17<br />

18 Route::put("event/{event}", [<br />

19 "as" => "event/update",<br />

20 "uses" => "EventController@update"<br />

21 ]);<br />

22

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

Saved successfully!

Ooh no, something went wrong!