🗃️ Ajouter un seeder de post pour tester
This commit is contained in:
parent
6ef79c10dd
commit
a7c8276aff
16
database/factories/PostFactory.php
Normal file
16
database/factories/PostFactory.php
Normal 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()
|
||||
];
|
||||
});
|
17
database/seeds/PostsTableSeeder.php
Normal file
17
database/seeds/PostsTableSeeder.php
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user