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

1 php artisan db:seed<br />

.<br />

If you kept the foreign key constraints (in the pivot table migrations); you will need to modify your<br />

seeder classes to include valid foreign keys.<br />

At this point; we should have the database tables set up, and some test data should be in the category<br />

and sponsor tables.<br />

Generating Models<br />

Before we can output data, we need a way to interface with the database. We’re going to use models<br />

for this purpose, so we should generate some:<br />

1 php artisan generate:model Event<br />

2<br />

3 php artisan generate:model Category<br />

4<br />

5 php artisan generate:model Sponsor<br />

These commands will generate stub models which resemble the following:<br />

1

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

Saved successfully!

Ooh no, something went wrong!