Created
February 16, 2014 13:35
-
-
Save subdesign/9034300 to your computer and use it in GitHub Desktop.
Faker 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ArticlesTableSeeder extends Seeder { | |
public function run() | |
{ | |
// létrehoz egy Faker objektumot | |
$faker = Faker\Factory::create(); | |
// 5 cikket hoz létre | |
foreach( range(1, 5) as $item ) | |
{ | |
Article::create(array( | |
// generál egy három szóból álló címet | |
'title' => $faker->sentence(3), | |
// generál egy 4 mondatból álló tartalmat | |
'content' => $faker->paragraph(4), | |
// a cikkek dátuma a mostani dátum és két héttel korábbani dátum között lesz véletlenszerűen | |
'created_at' => $faker->dateTimeBetween('now', '+14 days') | |
)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment