Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
phosphorylation
/
tecas-solar.ma
/
database
/
factories
:
CustomerFactory.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace Database\Factories; use App\Enums\CustomerTypeEnum; use App\Models\City; use App\Models\Country; use Illuminate\Database\Eloquent\Factories\Factory; /** * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Customer> */ class CustomerFactory extends Factory { /** * Define the model's default state. * * @return array<string, mixed> */ public function definition(): array { $customerType = array_map(fn ($status) => $status->value, CustomerTypeEnum::cases()); $country = Country::inRandomOrder()->first() ?? Country::factory()->create(); $city = City::where('country_id', $country->id)->inRandomOrder()->first() ?? City::factory()->create(['country_id' => $country->id]); return [ 'first_name' => $this->faker->firstName(), 'last_name' => $this->faker->lastName(), 'email' => $this->faker->unique()->safeEmail(), 'phone_number' => $this->faker->phoneNumber(), 'address' => $this->faker->address(), 'city_id' => $city->id, 'country_id' => $country->id, 'postal_code' => substr($this->faker->postcode(), 0, 5), 'birth_date' => $this->faker->date(), 'customer_type' => $this->faker->randomElement($customerType), ]; } }