/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); foreach (range(10, 1) as $num) { $faker = Faker\Factory::create('zh_TW'); Post::create(['title' => $faker->name, 'content' => $faker->sentence, 'id' => rand(0, 100), 'created_at' => $faker->dateTime($max = 'now'), 'updated_at' => Carbon::now()->subDays($num)->subYears(rand(1, 5))]); } }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); $faker = \Faker\Factory::create('zh_TW'); foreach (range(15, 1) as $number) { Post::create(['title' => $faker->sentence, 'content' => $faker->paragraph, 'is_feature' => rand(0, 1), 'created_at' => Carbon::now()->subDays($number), 'updated_at' => Carbon::now()->subDays($number)]); } }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); $faker = Factory::create('zh_tw'); foreach (range(10, 1) as $number) { Post::create(['title' => $faker->title, 'is_feature' => rand(0, 1), 'content' => $faker->name, 'created_at' => Carbon::now()->subDay($number), 'updated_at' => Carbon::now()->subDay($number)]); } }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); $faker = \Faker\Factory::create('zh_TW'); foreach (range(10, 1) as $number) { Post::create(['title' => $faker->Title, 'content' => $faker->Name, 'is_feature' => rand(0, 1), 'page_view' => rand(1, 1000), 'created_at' => Carbon::now()->subDay($number), 'updated_at' => Carbon::now()->subDay($number)]); } }
/** * Run the database seeds. * * @return void */ public function run() { Post::truncate(); foreach (range(1, 10) as $value) { $faker = \Faker\Factory::create('zh_TW'); Post::create(['title' => $faker->title, 'content' => $faker->name, 'is_feature' => rand(1, 0), 'page_view' => rand(1, 1000), 'created_at' => Carbon::now()->subDays($value), 'updated_at' => Carbon::now()->subDays($value)]); } }
public function run() { Post::truncate(); $faker = Faker\Factory::create(); $authorIds = User::lists('id'); for ($i = 0; $i < 10; $i++) { Post::create(['title' => $faker->word, 'desc' => $faker->sentence, 'image_url' => $faker->imageUrl($width = 640, $height = 480), 'share_url' => $faker->url, 'status' => $faker->randomElement(array(0, 1)), 'author_id' => $faker->randomElement($authorIds)]); } }
/** * Seed the posts table */ public function run() { // Pull all the tag names from the file $tags = Tag::lists('tag')->all(); Post::truncate(); // Don't forget to truncate the pivot table DB::table('post_tag_pivot')->truncate(); factory(Post::class, 20)->create()->each(function ($post) use($tags) { // 30% of the time don't assign a tag if (mt_rand(1, 100) <= 30) { return; } shuffle($tags); $postTags = [$tags[0]]; // 30% of the time we're assigning tags, assign 2 if (mt_rand(1, 100) <= 30) { $postTags[] = $tags[1]; } $post->syncTags($postTags); }); }