This commit is contained in:
f4ilji
2024-10-04 12:48:19 +05:00
parent 21a6e9073b
commit cebc584a14
303 changed files with 8224 additions and 2563 deletions
+7 -1
View File
@@ -2,7 +2,9 @@
namespace Database\Factories;
use App\Enums\PostStatus;
use App\Models\Category;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
@@ -33,12 +35,13 @@ class PostFactory extends Factory
],
];
}, range(1, $this->faker->numberBetween(1, 5)));
$status = $this->faker->randomElement(['verification', 'published', 'rejected']);
$status = $this->faker->randomElement([PostStatus::VERIFICATION, PostStatus::PUBLISHED, PostStatus::REJECTED]);
$authorsCount = $this->faker->numberBetween(1, 5);
$authors = array_fill(0, $authorsCount, $this->faker->name);
$imagesCount = $this->faker->numberBetween(1, 5);
$images = array_fill(0, $imagesCount, $this->faker->uuid . '.jpg');
$category_id = Category::inRandomOrder()->first();
$user_id = User::inRandomOrder()->first();
$search_data = $this->faker->words(10, true);
$reading_time = $this->faker->numberBetween(5, 30);
@@ -46,6 +49,7 @@ class PostFactory extends Factory
return [
'title' => $title,
'slug' => $slug,
'preview_text' => $this->faker->paragraph,
'content' => $content,
'status' => $status,
'authors' => $authors,
@@ -53,6 +57,8 @@ class PostFactory extends Factory
'search_data' => $search_data,
'reading_time' => $reading_time,
'category_id' => $category_id,
'user_id' => $user_id,
'publish_at' => ($status == PostStatus::PUBLISHED) ? now() : null,
'created_at' => now(),
'updated_at' => now(),
];