* 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>
This commit is contained in:
28
database/factories/ProfileFactory.php
Normal file
28
database/factories/ProfileFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Toby\Domain\Enums\EmploymentForm;
|
||||
use Toby\Eloquent\Models\Profile;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class ProfileFactory extends Factory
|
||||
{
|
||||
protected $model = Profile::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
"user_id" => User::factory(),
|
||||
"first_name" => $this->faker->firstName(),
|
||||
"last_name" => $this->faker->lastName(),
|
||||
"employment_form" => $this->faker->randomElement(EmploymentForm::cases()),
|
||||
"position" => $this->faker->jobTitle(),
|
||||
"employment_date" => Carbon::createFromInterface($this->faker->dateTimeBetween("2020-10-27"))->toDateString(),
|
||||
];
|
||||
}
|
||||
}
|
@@ -5,10 +5,9 @@ declare(strict_types=1);
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Toby\Domain\Enums\EmploymentForm;
|
||||
use Toby\Domain\Enums\Role;
|
||||
use Toby\Eloquent\Models\Profile;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class UserFactory extends Factory
|
||||
@@ -18,17 +17,21 @@ class UserFactory extends Factory
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
"first_name" => $this->faker->firstName(),
|
||||
"last_name" => $this->faker->lastName(),
|
||||
"email" => $this->faker->unique()->safeEmail(),
|
||||
"employment_form" => $this->faker->randomElement(EmploymentForm::cases()),
|
||||
"position" => $this->faker->jobTitle(),
|
||||
"role" => Role::Employee,
|
||||
"employment_date" => Carbon::createFromInterface($this->faker->dateTimeBetween("2020-10-27"))->toDateString(),
|
||||
"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([
|
||||
|
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
return new class() extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create("profiles", function (Blueprint $table): void {
|
||||
$table->foreignIdFor(User::class)->primary();
|
||||
$table->string("first_name")->nullable();
|
||||
$table->string("last_name")->nullable();
|
||||
$table->string("position")->nullable();
|
||||
$table->string("employment_form")->nullable();
|
||||
$table->date("employment_date")->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists("profiles");
|
||||
}
|
||||
};
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Artisan::call("toby:move-user-data-to-profile");
|
||||
|
||||
Schema::table("users", function (Blueprint $table): void {
|
||||
$table->dropColumn("first_name");
|
||||
$table->dropColumn("last_name");
|
||||
$table->dropColumn("position");
|
||||
$table->dropColumn("employment_form");
|
||||
$table->dropColumn("employment_date");
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table("users", function (Blueprint $table): void {
|
||||
$table->string("first_name")->nullable();
|
||||
$table->string("last_name")->nullable();
|
||||
$table->string("position")->nullable();
|
||||
$table->string("employment_form")->nullable();
|
||||
$table->date("employment_date")->nullable();
|
||||
});
|
||||
}
|
||||
};
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table("users", function (Blueprint $table): void {
|
||||
$table->timestamp("last_active_at")->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table("users", function (Blueprint $table): void {
|
||||
$table->dropColumn("last_active_at");
|
||||
});
|
||||
}
|
||||
};
|
@@ -30,75 +30,87 @@ class DemoSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
$user = User::factory([
|
||||
"first_name" => "Jan",
|
||||
"last_name" => "Kowalski",
|
||||
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
||||
"employment_form" => EmploymentForm::EmploymentContract,
|
||||
"position" => "programista",
|
||||
"role" => Role::Administrator,
|
||||
"employment_date" => Carbon::createFromDate(2021, 12, 31),
|
||||
"remember_token" => Str::random(10),
|
||||
])
|
||||
->hasProfile([
|
||||
"first_name" => "Jan",
|
||||
"last_name" => "Kowalski",
|
||||
"employment_form" => EmploymentForm::EmploymentContract,
|
||||
"position" => "programista",
|
||||
"employment_date" => Carbon::createFromDate(2021, 12, 31),
|
||||
])
|
||||
->create();
|
||||
|
||||
User::factory([
|
||||
"first_name" => "Anna",
|
||||
"last_name" => "Nowak",
|
||||
"email" => "anna.nowak@example.com",
|
||||
"employment_form" => EmploymentForm::CommissionContract,
|
||||
"position" => "tester",
|
||||
"role" => Role::Employee,
|
||||
"employment_date" => Carbon::createFromDate(2021, 5, 10),
|
||||
"remember_token" => Str::random(10),
|
||||
])
|
||||
->hasProfile([
|
||||
"first_name" => "Anna",
|
||||
"last_name" => "Nowak",
|
||||
"employment_form" => EmploymentForm::CommissionContract,
|
||||
"position" => "tester",
|
||||
"employment_date" => Carbon::createFromDate(2021, 5, 10),
|
||||
])
|
||||
->create();
|
||||
|
||||
User::factory([
|
||||
"first_name" => "Tola",
|
||||
"last_name" => "Sawicka",
|
||||
"email" => "tola.sawicka@example.com",
|
||||
"employment_form" => EmploymentForm::B2bContract,
|
||||
"position" => "programista",
|
||||
"role" => Role::Employee,
|
||||
"employment_date" => Carbon::createFromDate(2021, 1, 4),
|
||||
"remember_token" => Str::random(10),
|
||||
])
|
||||
->hasProfile([
|
||||
"first_name" => "Tola",
|
||||
"last_name" => "Sawicka",
|
||||
"employment_form" => EmploymentForm::B2bContract,
|
||||
"position" => "programista",
|
||||
"employment_date" => Carbon::createFromDate(2021, 1, 4),
|
||||
])
|
||||
->create();
|
||||
|
||||
$technicalApprover = User::factory([
|
||||
"first_name" => "Maciej",
|
||||
"last_name" => "Ziółkowski",
|
||||
"email" => "maciej.ziolkowski@example.com",
|
||||
"employment_form" => EmploymentForm::BoardMemberContract,
|
||||
"position" => "programista",
|
||||
"role" => Role::TechnicalApprover,
|
||||
"employment_date" => Carbon::createFromDate(2021, 1, 4),
|
||||
"remember_token" => Str::random(10),
|
||||
])
|
||||
->hasProfile([
|
||||
"first_name" => "Maciej",
|
||||
"last_name" => "Ziółkowski",
|
||||
"employment_form" => EmploymentForm::BoardMemberContract,
|
||||
"position" => "programista",
|
||||
"employment_date" => Carbon::createFromDate(2021, 1, 4),
|
||||
])
|
||||
->create();
|
||||
|
||||
$administrativeApprover = User::factory([
|
||||
"first_name" => "Katarzyna",
|
||||
"last_name" => "Zając",
|
||||
"email" => "katarzyna.zajac@example.com",
|
||||
"employment_form" => EmploymentForm::EmploymentContract,
|
||||
"position" => "dyrektor",
|
||||
"role" => Role::AdministrativeApprover,
|
||||
"employment_date" => Carbon::createFromDate(2021, 1, 4),
|
||||
"remember_token" => Str::random(10),
|
||||
])
|
||||
->hasProfile([
|
||||
"first_name" => "Katarzyna",
|
||||
"last_name" => "Zając",
|
||||
"employment_form" => EmploymentForm::EmploymentContract,
|
||||
"position" => "dyrektor",
|
||||
"employment_date" => Carbon::createFromDate(2021, 1, 4),
|
||||
])
|
||||
->create();
|
||||
|
||||
User::factory([
|
||||
"first_name" => "Miłosz",
|
||||
"last_name" => "Borowski",
|
||||
"email" => "milosz.borowski@example.com",
|
||||
"employment_form" => EmploymentForm::EmploymentContract,
|
||||
"position" => "administrator",
|
||||
"role" => Role::Administrator,
|
||||
"employment_date" => Carbon::createFromDate(2021, 1, 4),
|
||||
"remember_token" => Str::random(10),
|
||||
])
|
||||
->hasProfile([
|
||||
"first_name" => "Miłosz",
|
||||
"last_name" => "Borowski",
|
||||
"employment_form" => EmploymentForm::EmploymentContract,
|
||||
"position" => "administrator",
|
||||
"employment_date" => Carbon::createFromDate(2021, 1, 4),
|
||||
])
|
||||
->create();
|
||||
|
||||
$users = User::all();
|
||||
@@ -118,7 +130,7 @@ class DemoSeeder extends Seeder
|
||||
->afterCreating(function (YearPeriod $yearPeriod) use ($users): void {
|
||||
foreach ($users as $user) {
|
||||
VacationLimit::factory([
|
||||
"days" => $user->employment_form === EmploymentForm::EmploymentContract ? 26 : null,
|
||||
"days" => $user->profile->employment_form === EmploymentForm::EmploymentContract ? 26 : null,
|
||||
])
|
||||
->for($yearPeriod)
|
||||
->for($user)
|
||||
|
Reference in New Issue
Block a user