Initial commit of the L'Ami Fiduciaire SaaS platform built on Laravel 12, Vue 3, Inertia.js 2, and Tailwind CSS 4. Story 0.1 (rename folders to declarations in database) is implemented and code-reviewed: migration, rollback, and 6 Pest tests all passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
64 lines
1.9 KiB
PHP
64 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\ClientStatus;
|
|
use App\Enums\LegalForm;
|
|
use App\Models\ClientContact;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Client>
|
|
*/
|
|
class ClientFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'workspace_id' => Workspace::factory(),
|
|
'company_name' => fake()->company(),
|
|
'legal_form' => fake()->randomElement(LegalForm::getValues()),
|
|
'ice' => (string) fake()->numerify('##########'),
|
|
'fiscal_id' => (string) fake()->numerify('##########'),
|
|
'rc' => (string) fake()->numerify('######'),
|
|
'cnss' => (string) fake()->numerify('##########'),
|
|
'patente' => (string) fake()->numerify('########'),
|
|
'contact_last_name' => fake()->lastName(),
|
|
'contact_first_name' => fake()->firstName(),
|
|
'contact_job_title' => fake()->jobTitle(),
|
|
'contact_email' => fake()->unique()->safeEmail(),
|
|
'contact_phone' => fake()->phoneNumber(),
|
|
'internal_responsible_id' => null,
|
|
'status' => ClientStatus::Active,
|
|
'internal_notes' => fake()->optional(0.3)->sentence(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Configure the model factory.
|
|
*/
|
|
public function configure(): static
|
|
{
|
|
return $this->afterCreating(function ($client) {
|
|
ClientContact::factory()->principal()->create([
|
|
'client_id' => $client->id,
|
|
]);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Associate the client with an internal responsible user.
|
|
*/
|
|
public function withInternalResponsible(User $user): static
|
|
{
|
|
return $this->state(fn () => ['internal_responsible_id' => $user->id]);
|
|
}
|
|
}
|