03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

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

E-Commerce 236<br />

.<br />

You can learn more about models at: http://laravel.com/docs/eloquent.<br />

Creating Seeders<br />

Having installed Faker; we’re going to use it to populate the database tables with fake data. We do<br />

this for two reasons. Firstly, using fake data is safer than using production data.<br />

Have you ever been writing a script that sends out emails and used some dummy<br />

copy while you’re building it? Ever used some cheeky words in that content? Ever<br />

accidentally sent that email out to 10,000 real customers email addresses? Ever been<br />

fired for losing a company north of £200,000?<br />

I haven’t, but I know a guy that has. Don’t be that guy.<br />

• Phil Sturgeon, Build APIs You Won’t Hate<br />

Secondly, Faker provides random fake data so we get to see what our models look like with random<br />

variable data. This will show us the oft-overlooked field limits and formatting errors that we tend<br />

to miss while using the same set of pre-defined seed data.<br />

Using Faker is easy:<br />

1

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

Saved successfully!

Ooh no, something went wrong!