mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-05-07 20:32:26 +00:00
47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Client;
|
|
use App\Models\Organization;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Client>
|
|
*/
|
|
class ClientFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => $this->faker->company(),
|
|
'organization_id' => Organization::factory(),
|
|
];
|
|
}
|
|
|
|
public function forOrganization(Organization $organization): self
|
|
{
|
|
return $this->state(function (array $attributes) use ($organization) {
|
|
return [
|
|
'organization_id' => $organization->getKey(),
|
|
];
|
|
});
|
|
}
|
|
|
|
public function randomCreatedAt(): self
|
|
{
|
|
return $this->state(function (array $attributes): array {
|
|
return [
|
|
'created_at' => $this->faker->dateTimeBetween('-1 day', 'now'),
|
|
];
|
|
});
|
|
}
|
|
}
|