06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Release Notes 11<br />

For more information on testing, check out the testing documentation.<br />

Model Factories<br />

Laravel now ships with an easy way to create stub Eloquent models using model factories. Model<br />

factories allow you to easily define a set of “default” attributes for your Eloquent model, and then<br />

generate test model instances for your tests or database seeds. Model factories also take advantage<br />

of the powerful Faker³ PHP library for generating random attribute data:<br />

1 $factory->define(App\User::class, function ($faker) {<br />

2 return [<br />

3 'name' => $faker->name,<br />

4 'email' => $faker->email,<br />

5 'password' => str_random(10),<br />

6 'remember_token' => str_random(10),<br />

7 ];<br />

8 });<br />

For more information on model factories, check out the documentation.<br />

Artisan Improvements<br />

Artisan commands may now be defined using a simple, route-like “signature”, which provides an<br />

extremely simple interface for defining command line arguments and options. For example, you<br />

may define a simple command and its options like so:<br />

1 /**<br />

2 * The name and signature of the console command.<br />

3 *<br />

4 * @var string<br />

5 */<br />

6 protected $signature = 'email:send {user} {--force}';<br />

For more information on defining Artisan commands, consult the Artisan documentation.<br />

³https://github.com/fzaninotto/Faker

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

Saved successfully!

Ooh no, something went wrong!