mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-13 18:52:14 +01:00
Added placeholder users; Better exception handling; Enhanced local setup
This commit is contained in:
@@ -27,10 +27,10 @@ class OrganizationFactory extends Factory
|
||||
];
|
||||
}
|
||||
|
||||
public function withOwner(): self
|
||||
public function withOwner(?User $owner = null): self
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'user_id' => User::factory(),
|
||||
'user_id' => $owner === null ? User::factory() : $owner,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,19 @@ class UserFactory extends Factory
|
||||
'remember_token' => Str::random(10),
|
||||
'profile_photo_path' => null,
|
||||
'current_team_id' => null,
|
||||
'is_placeholder' => false,
|
||||
];
|
||||
}
|
||||
|
||||
public function placeholder(bool $placeholder = true): static
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($placeholder): array {
|
||||
return [
|
||||
'is_placeholder' => $placeholder,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
|
||||
@@ -22,31 +22,57 @@ class DatabaseSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
$this->deleteAll();
|
||||
$organization1 = Organization::factory()->create([
|
||||
$userAcmeOwner = User::factory()->create([
|
||||
'name' => 'ACME Admin',
|
||||
'email' => 'owner@acme.test',
|
||||
]);
|
||||
$organizationAcme = Organization::factory()->withOwner($userAcmeOwner)->create([
|
||||
'name' => 'ACME Corp',
|
||||
]);
|
||||
$user1 = User::factory()->withPersonalOrganization()->create([
|
||||
$userAcmeManager = User::factory()->withPersonalOrganization()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
$employee1 = User::factory()->withPersonalOrganization()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'employee@example.com',
|
||||
]);
|
||||
$userAcmeAdmin = User::factory()->create([
|
||||
$userAcmeAdmin = User::factory()->withPersonalOrganization()->create([
|
||||
'name' => 'ACME Admin',
|
||||
'email' => 'admin@acme.test',
|
||||
]);
|
||||
$user1->organizations()->attach($organization1, [
|
||||
$userAcmeEmployee = User::factory()->withPersonalOrganization()->create([
|
||||
'name' => 'Max Mustermann',
|
||||
'email' => 'max.mustermann@acme.test',
|
||||
]);
|
||||
$userAcmePlaceholder = User::factory()->placeholder()->create([
|
||||
'name' => 'Old Employee',
|
||||
'email' => 'old.employee@acme.test',
|
||||
'password' => null,
|
||||
]);
|
||||
$userAcmeManager->organizations()->attach($organizationAcme, [
|
||||
'role' => 'manager',
|
||||
]);
|
||||
$userAcmeAdmin->organizations()->attach($organization1, [
|
||||
$userAcmeAdmin->organizations()->attach($organizationAcme, [
|
||||
'role' => 'admin',
|
||||
]);
|
||||
$timeEntriesEmployees = TimeEntry::factory()
|
||||
$userAcmeEmployee->organizations()->attach($organizationAcme, [
|
||||
'role' => 'employee',
|
||||
]);
|
||||
$userAcmePlaceholder->organizations()->attach($organizationAcme, [
|
||||
'role' => 'employee',
|
||||
]);
|
||||
|
||||
$timeEntriesAcmeAdmin = TimeEntry::factory()
|
||||
->count(10)
|
||||
->forUser($employee1)
|
||||
->forOrganization($organization1)
|
||||
->forUser($userAcmeAdmin)
|
||||
->forOrganization($organizationAcme)
|
||||
->create();
|
||||
$timeEntriesAcmePlaceholder = TimeEntry::factory()
|
||||
->count(10)
|
||||
->forUser($userAcmePlaceholder)
|
||||
->forOrganization($organizationAcme)
|
||||
->create();
|
||||
$timeEntriesAcmePlaceholder = TimeEntry::factory()
|
||||
->count(10)
|
||||
->forUser($userAcmeEmployee)
|
||||
->forOrganization($organizationAcme)
|
||||
->create();
|
||||
$client = Client::factory()->create([
|
||||
'name' => 'Big Company',
|
||||
@@ -63,11 +89,11 @@ class DatabaseSeeder extends Seeder
|
||||
$organization2 = Organization::factory()->create([
|
||||
'name' => 'Rival Corp',
|
||||
]);
|
||||
$user1 = User::factory()->withPersonalOrganization()->create([
|
||||
$userAcmeManager = User::factory()->withPersonalOrganization()->create([
|
||||
'name' => 'Other User',
|
||||
'email' => 'test@rival-company.test',
|
||||
]);
|
||||
$user1->organizations()->attach($organization2, [
|
||||
$userAcmeManager->organizations()->attach($organization2, [
|
||||
'role' => 'admin',
|
||||
]);
|
||||
$otherCompanyProject = Project::factory()->forClient($client)->create([
|
||||
|
||||
Reference in New Issue
Block a user