php-tenant/Database/Factories/WorkspaceInvitationFactory.php
Snider d0ad2737cb refactor: rename namespace from Core\Mod\Tenant to Core\Tenant
Simplifies the namespace hierarchy by removing the intermediate Mod
segment. Updates all 118 files including models, services, controllers,
middleware, tests, and composer.json autoload configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 16:30:46 +00:00

75 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Tenant\Database\Factories;
use Core\Tenant\Models\WorkspaceInvitation;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Core\Tenant\Models\WorkspaceInvitation>
*/
class WorkspaceInvitationFactory extends Factory
{
protected $model = WorkspaceInvitation::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'email' => fake()->unique()->safeEmail(),
'token' => Str::random(64),
'role' => 'member',
'invited_by' => null,
'expires_at' => now()->addDays(7),
'accepted_at' => null,
];
}
/**
* Indicate the invitation has been accepted.
*/
public function accepted(): static
{
return $this->state(fn (array $attributes) => [
'accepted_at' => fake()->dateTimeBetween('-7 days', 'now'),
]);
}
/**
* Indicate the invitation has expired.
*/
public function expired(): static
{
return $this->state(fn (array $attributes) => [
'expires_at' => fake()->dateTimeBetween('-30 days', '-1 day'),
'accepted_at' => null,
]);
}
/**
* Set the role to admin.
*/
public function asAdmin(): static
{
return $this->state(fn (array $attributes) => [
'role' => 'admin',
]);
}
/**
* Set the role to owner.
*/
public function asOwner(): static
{
return $this->state(fn (array $attributes) => [
'role' => 'owner',
]);
}
}