🗃️ Ajouter un seeder de post pour tester

This commit is contained in:
cdesmidt 2019-10-01 16:21:51 +02:00
parent 6ef79c10dd
commit a7c8276aff
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,16 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Model;
use Faker\Generator as Faker;
$factory->define(\App\Post::class, function (Faker $faker) {
return [
'user_id' => 1,
'date_post' => $faker->dateTimeBetween('-1 year'),
// 'date_post' => \Carbon\Carbon::createFromFormat('Y-n-d', rand(2018,2019), rand(1,12), rand(1,28)),
'content' => $faker->sentences(3, true),
'created_at' => \Carbon\Carbon::now()
];
});

View File

@ -0,0 +1,17 @@
<?php
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class PostsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$users = factory(App\Post::class, 100)->create();
}
}