Added billable rates; Added project members; Added visibility to projects

This commit is contained in:
Constantin Graf
2024-03-28 18:50:04 +01:00
parent bb42b0940a
commit ba0212ea01
71 changed files with 3236 additions and 174 deletions

View File

@@ -7,6 +7,8 @@ namespace Database\Factories;
use App\Models\Client;
use App\Models\Organization;
use App\Models\Project;
use App\Models\ProjectMember;
use App\Models\User;
use App\Service\ColorService;
use Illuminate\Database\Eloquent\Factories\Factory;
@@ -25,8 +27,10 @@ class ProjectFactory extends Factory
return [
'name' => $this->faker->company(),
'color' => app(ColorService::class)->getRandomColor(),
'organization_id' => Organization::factory(),
'billable_rate' => $this->faker->numberBetween(50, 1000) * 100,
'is_public' => false,
'client_id' => null,
'organization_id' => Organization::factory(),
];
}
@@ -39,6 +43,34 @@ class ProjectFactory extends Factory
});
}
public function isPublic(): self
{
return $this->state(function (array $attributes): array {
return [
'is_public' => true,
];
});
}
public function isPrivate(): self
{
return $this->state(function (array $attributes): array {
return [
'is_public' => false,
];
});
}
public function addMember(User $user, array $attributes = []): self
{
return $this->afterCreating(function (Project $project) use ($user, $attributes): void {
ProjectMember::factory()
->forProject($project)
->forUser($user)
->create($attributes);
});
}
public function withClient(): self
{
return $this->state(function (array $attributes): array {