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.

E-Commerce 243<br />

33<br />

34 $used[] = $product["id"];<br />

35 }<br />

36 }<br />

37 }<br />

38 }<br />

39 }<br />

.<br />

This file should be saved as app/database/seeds/OrderItemTableSeeder.php.<br />

1 public function run()<br />

2 {<br />

3 $this->call("AccountTableSeeder");<br />

4 $this->call("CategoryTableSeeder");<br />

5 $this->call("ProductTableSeeder");<br />

6 $this->call("OrderTableSeeder");<br />

7 $this->call("OrderItemTableSeeder");<br />

8 }<br />

.<br />

This was extracted from app/database/seeds/DatabaseSeeder.php.<br />

.<br />

You can learn more about seeders at: http://laravel.com/docs/migrations#database-seeding and<br />

more about Faker at: https://github.com/fzaninotto/Faker.<br />

The order in which we call the seeders is important. We can’t start populating orders and order<br />

items if we have no products or accounts in the database…<br />

Creating API Endpoints<br />

We don’t have time to cover all aspects of creating APIs with Laravel 4, so we’ll confine our efforts<br />

to creating endpoints for the basic interactions that need to happen for our interface to function.

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

Saved successfully!

Ooh no, something went wrong!