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 114<br />

12 */<br />

13 public function up()<br />

14 {<br />

15 Schema::create('event', function(Blueprint $table) {<br />

16 $table->increments('id');<br />

17<br />

18 $table->timestamps();<br />

19 });<br />

20 }<br />

21<br />

22 /**<br />

23 * Reverse the migrations.<br />

24 *<br />

25 * @return void<br />

26 */<br />

27 public function down()<br />

28 {<br />

29 Schema::drop('event');<br />

30 }<br />

31 }<br />

This file should be saved as app/database/migrations/00000000_000000_create_event_table.php.<br />

.<br />

We’ve seen these kinds of migrations before, so there’s not much to say about this one. The generators<br />

allow us to take it a step further by providing field names and types:<br />

1 php artisan generate:migration --fields="name:string, description:text, started_a\<br />

2 t:timestamp, ended_at:timestamp" create_event_table<br />

This command alters the up() method previously generated:

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

Saved successfully!

Ooh no, something went wrong!