diff --git a/database/factories/SchoolFactory.php b/database/factories/SchoolFactory.php index c2000bc..b504073 100644 --- a/database/factories/SchoolFactory.php +++ b/database/factories/SchoolFactory.php @@ -20,10 +20,10 @@ public function definition(): array 'name' => fake()->company(), 'address' => fake()->address(), 'phone' => fake()->phoneNumber(), - 'logo' => fake()->imageUrl(200, 200, 'schools', true, 'School'), - 'country' => fake()->country(), - 'city' => fake()->city(), - 'location' => fake()->address(), + 'email' => fake()->unique()->safeEmail(), + 'website' => fake()->optional()->url(), + 'description' => fake()->optional()->paragraph(), + 'status' => 'active', ]; } } diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 33ece4e..bdcec05 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -2,8 +2,8 @@ namespace Database\Factories; -use App\Models\School; use Illuminate\Database\Eloquent\Factories\Factory; +use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; /** @@ -11,37 +11,35 @@ */ class UserFactory extends Factory { + /** + * The current password being used by the factory. + */ protected static ?string $password; + /** + * Define the model's default state. + * + * @return array + */ public function definition(): array { - $gender = fake()->randomElement(['Male', 'Female']); - return [ - 'name' => $gender === 'Male' ? fake()->name('male') : fake()->name('female'), + 'name' => fake()->name(), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), - 'password' => 'password', + 'password' => static::$password ??= Hash::make('password'), 'remember_token' => Str::random(10), - - // Additional fields - 'avatar' => fake()->imageUrl(300, 300, 'people', true, 'User'), - 'phone' => '5'.fake()->numerify('########'), // Saudi Arabian phone number format - 'phone_zone' => '+966', - 'whatsapp' => '5'.fake()->numerify('########'), - 'whatsapp_zone' => '+966', - 'gender' => $gender, - 'birth_date' => fake()->dateTimeBetween('-40 years', '-18 years')->format('Y-m-d'), - 'country' => 'Saudi Arabia', - 'city' => fake()->randomElement(['Riyadh', 'Jeddah', 'Dammam', 'Mecca', 'Medina']), - 'residence' => fake()->streetName(), - 'status' => 'active', - - // Ensure there's a related school (or use create method) - 'school_id' => School::factory(), + 'phone' => fake()->phoneNumber(), + 'gender' => fake()->randomElement(['Male', 'Female']), + 'birth_date' => fake()->date(), + 'country' => fake()->country(), + 'city' => fake()->city(), ]; } + /** + * Indicate that the model's email address should be unverified. + */ public function unverified(): static { return $this->state(fn (array $attributes) => [