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

We’re going to use Faker for populating our database tables (through seeders) so we have a fresh set<br />

of data to use each time we migrate our database objects.<br />

To install Faker; add another Composer dependency:<br />

1 "require" : {<br />

2 "fzaninotto/faker" : "dev-master"<br />

3 }<br />

.<br />

This was extracted from composer.json.<br />

Remember to make this dependency behave nicely with the others in composer.json. A simple<br />

composer update should take us the rest of the way to being able to use DOMPDF, Stripe and Faker<br />

in our application.<br />

Creating Database Objects<br />

For our online shop; we’re going to need categories for products to be sorted into, products and<br />

accounts. We’ll also need orders and order items, to track which items have been sold.<br />

Creating Migrations<br />

We listed five migrations, which we need to create. Fire up a terminal window and use the following<br />

command to create them:<br />

1 php artisan migrate:make CreateCategoryTable<br />

.<br />

You can repeat this process five times, or you can use the first as a copy-and-paste template for the<br />

remaining four migrations.<br />

After a bit of modification; I have the following migrations:

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

Saved successfully!

Ooh no, something went wrong!