diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php index d29d9fe..2d742cc 100644 --- a/database/factories/CompanyFactory.php +++ b/database/factories/CompanyFactory.php @@ -2,6 +2,7 @@ namespace Database\Factories; +use App\Enums\VerificationStatus; use App\Models\Company; use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; @@ -34,8 +35,8 @@ public function definition(): array 'annual_tax_return' => $this->faker->numerify('SPT-####-########'), 'domicile_certificate' => $this->faker->numerify('###/###/DOMISILI/####'), 'profile' => $this->faker->numerify('PROFILE-####-########'), - 'validated_at' => $this->faker->optional(0.7)->dateTimeBetween('-1 year', 'now'), - 'rejection_reason' => $this->faker->optional(0.1)->sentence(), + 'profile' => $this->faker->numerify('PROFILE-####-########'), + 'status' => VerificationStatus::PENDING, ]; } @@ -45,8 +46,7 @@ public function definition(): array public function validated(): static { return $this->state(fn (array $attributes) => [ - 'validated_at' => $this->faker->dateTimeBetween('-6 months', 'now'), - 'rejection_reason' => null, + 'status' => VerificationStatus::APPROVED, ]); } @@ -56,8 +56,7 @@ public function validated(): static public function rejected(): static { return $this->state(fn (array $attributes) => [ - 'validated_at' => null, - 'rejection_reason' => $this->faker->sentence(), + 'status' => VerificationStatus::REJECTED, ]); } @@ -67,8 +66,7 @@ public function rejected(): static public function pending(): static { return $this->state(fn (array $attributes) => [ - 'validated_at' => null, - 'rejection_reason' => null, + 'status' => VerificationStatus::PENDING, ]); } } diff --git a/database/factories/PartnerMediaFactory.php b/database/factories/PartnerMediaFactory.php index 6560533..4b26fa5 100644 --- a/database/factories/PartnerMediaFactory.php +++ b/database/factories/PartnerMediaFactory.php @@ -43,7 +43,7 @@ public function definition(): array 'company_id' => Company::factory(), 'name' => $this->faker->randomElement($mediaNames), 'address' => $this->faker->address(), - 'link' => $this->faker->optional(0.8)->url(), + 'link' => $this->faker->optional(0.8)->domainName(), 'type' => $this->faker->randomElement(MediaType::cases())->value, 'classification' => $this->faker->randomElement(MediaClassification::cases())->value, 'journalism_organization' => $this->faker->optional(0.6)->randomElement([ @@ -63,7 +63,7 @@ public function online(): static { return $this->state(fn (array $attributes) => [ 'type' => MediaType::ONLINE->value, - 'link' => $this->faker->url(), + 'link' => $this->faker->domainName(), ]); } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 87ee10c..63a39b2 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -26,7 +26,7 @@ public function definition(): array return [ 'name' => fake()->name(), 'email' => fake()->unique()->safeEmail(), - 'username' => $this->faker->unique()->userName(), + 'username' => $this->faker->unique()->bothify('?????#####'), 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), 'remember_token' => Str::random(10), diff --git a/database/seeders/CompanySeeder.php b/database/seeders/CompanySeeder.php new file mode 100644 index 0000000..3e1eea4 --- /dev/null +++ b/database/seeders/CompanySeeder.php @@ -0,0 +1,30 @@ +count(3) + ->create() + ->each(function ($media) { + // Assign role to the user associated with the company + $media->company->user->assignRole(RoleEnum::PERUSAHAAN); + + // Create journalists for the media + Journalist::factory() + ->count(random_int(1, 3)) + ->create(['partner_media_id' => $media->id]); + }); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 6b43e93..f1295ca 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -17,6 +17,7 @@ public function run(): void $this->call([ ShieldSeeder::class, UserSeeder::class, + CompanySeeder::class, ]); } }