-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathArticleFactory.php
More file actions
38 lines (33 loc) · 852 Bytes
/
ArticleFactory.php
File metadata and controls
38 lines (33 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Database\Factories;
use App\Models\Article;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Article>
*/
class ArticleFactory extends Factory
{
public function definition(): array
{
return [
'author_id' => User::factory(),
'slug' => fake()->unique()->slug(3),
'title' => fake()->sentence(),
'excerpt' => fake()->paragraph(1, false),
'content' => implode(PHP_EOL.PHP_EOL, fake()->paragraphs()),
];
}
public function published(): static
{
return $this->state(fn () => [
'published_at' => now(),
]);
}
public function scheduled(): static
{
return $this->state(fn () => [
'published_at' => now()->addMinute(),
]);
}
}