Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions database/factories/SchoolFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
}
}
40 changes: 19 additions & 21 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,44 @@

namespace Database\Factories;

use App\Models\School;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
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) => [
Expand Down