completed story 1.1 with QA tests and fixes

This commit is contained in:
Naser Mansour
2025-12-26 13:46:39 +02:00
parent 028ce573b9
commit 84d9c2f66a
57 changed files with 2193 additions and 85 deletions
+84 -5
View File
@@ -2,6 +2,8 @@
namespace Database\Factories;
use App\Enums\UserStatus;
use App\Enums\UserType;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
@@ -24,14 +26,16 @@ class UserFactory extends Factory
public function definition(): array
{
return [
'name' => fake()->name(),
'user_type' => UserType::Individual,
'full_name' => fake()->name(),
'national_id' => fake()->numerify('#########'),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'phone' => fake()->phoneNumber(),
'password' => static::$password ??= Hash::make('password'),
'status' => UserStatus::Active,
'preferred_language' => fake()->randomElement(['ar', 'en']),
'email_verified_at' => now(),
'remember_token' => Str::random(10),
'two_factor_secret' => Str::random(10),
'two_factor_recovery_codes' => Str::random(10),
'two_factor_confirmed_at' => now(),
];
}
@@ -45,6 +49,81 @@ class UserFactory extends Factory
]);
}
/**
* Create an admin user.
*/
public function admin(): static
{
return $this->state(fn (array $attributes) => [
'user_type' => UserType::Admin,
'company_name' => null,
'company_cert_number' => null,
'contact_person_name' => null,
'contact_person_id' => null,
]);
}
/**
* Create an individual client user.
*/
public function individual(): static
{
return $this->state(fn (array $attributes) => [
'user_type' => UserType::Individual,
'company_name' => null,
'company_cert_number' => null,
'contact_person_name' => null,
'contact_person_id' => null,
]);
}
/**
* Create a company client user.
*/
public function company(): static
{
return $this->state(fn (array $attributes) => [
'user_type' => UserType::Company,
'national_id' => null,
'company_name' => fake()->company(),
'company_cert_number' => fake()->numerify('CR-######'),
'contact_person_name' => fake()->name(),
'contact_person_id' => fake()->numerify('#########'),
]);
}
/**
* Create a client user (individual or company).
*/
public function client(): static
{
return fake()->boolean()
? $this->individual()
: $this->company();
}
/**
* Create a deactivated user.
*/
public function deactivated(): static
{
return $this->state(fn (array $attributes) => [
'status' => UserStatus::Deactivated,
]);
}
/**
* Indicate that the model has two-factor authentication configured.
*/
public function withTwoFactor(): static
{
return $this->state(fn (array $attributes) => [
'two_factor_secret' => Str::random(10),
'two_factor_recovery_codes' => Str::random(10),
'two_factor_confirmed_at' => now(),
]);
}
/**
* Indicate that the model does not have two-factor authentication configured.
*/