Added post seeder

main
TZGyn 3 years ago
parent 0c6c25afbe
commit 98d945b650
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -0,0 +1,24 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Post>
*/
class PostFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'title' => fake()->sentence,
'description' => collect(fake()->paragraphs)->implode(' '),
];
}
}

@ -18,5 +18,9 @@ class DatabaseSeeder extends Seeder
// 'name' => 'Test User', // 'name' => 'Test User',
// 'email' => 'test@example.com', // 'email' => 'test@example.com',
// ]); // ]);
//
$this->call([
PostSeeder::class,
]);
} }
} }

@ -0,0 +1,20 @@
<?php
namespace Database\Seeders;
use App\Models\Post;
use Illuminate\Database\Seeder;
class PostSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
Post::factory()
->count(200)
->create();
}
}
Loading…
Cancel
Save