
* fix css focuses * #90 - wip * #90 - fix to generate PDF * #90 - wip * #90 - wip * #90 - wip * #90 - wip * #90 - fix to calendar * #90 - wip * #90 - fix * #90 - fix lint * #90 - fix * Apply suggestions from code review Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * #90 - cr fixes * #90 - fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
use Toby\Domain\Enums\Role;
|
|
use Toby\Eloquent\Models\Profile;
|
|
use Toby\Eloquent\Models\User;
|
|
|
|
class UserFactory extends Factory
|
|
{
|
|
protected $model = User::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
"email" => $this->faker->unique()->safeEmail(),
|
|
"role" => Role::Employee,
|
|
"remember_token" => Str::random(10),
|
|
];
|
|
}
|
|
|
|
public function configure(): self
|
|
{
|
|
return $this->afterCreating(function (User $user): void {
|
|
if (!$user->profile()->exists()) {
|
|
Profile::factory()->for($user)->create();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function admin(): static
|
|
{
|
|
return $this->state([
|
|
"role" => Role::Administrator,
|
|
]);
|
|
}
|
|
|
|
public function technicalApprover(): static
|
|
{
|
|
return $this->state([
|
|
"role" => Role::TechnicalApprover,
|
|
]);
|
|
}
|
|
|
|
public function administrativeApprover(): static
|
|
{
|
|
return $this->state([
|
|
"role" => Role::AdministrativeApprover,
|
|
]);
|
|
}
|
|
}
|