#20 - wip
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Toby\Enums\EmploymentForm;
|
||||
use Toby\Enums\Role;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
@@ -18,6 +19,7 @@ class UserFactory extends Factory
|
||||
"last_name" => $this->faker->lastName(),
|
||||
"email" => $this->faker->unique()->safeEmail(),
|
||||
"employment_form" => $this->faker->randomElement(EmploymentForm::cases()),
|
||||
"role" => Role::EMPLOYEE,
|
||||
"employment_date" => Carbon::createFromInterface($this->faker->dateTimeBetween("2020-10-27"))->toDateString(),
|
||||
"remember_token" => Str::random(10),
|
||||
];
|
||||
|
29
database/factories/VacationRequestFactory.php
Normal file
29
database/factories/VacationRequestFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Toby\Enums\VacationRequestState;
|
||||
use Toby\Enums\VacationType;
|
||||
use Toby\Models\User;
|
||||
|
||||
class VacationRequestFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
$number = $this->faker->numberBetween(1, 20);
|
||||
$year = $this->faker->year;
|
||||
|
||||
return [
|
||||
"user_id" => User::factory(),
|
||||
"name" => "{$number}/{$year}",
|
||||
"type" => $this->faker->randomElement(VacationType::cases()),
|
||||
"state" => $this->faker->randomElement(VacationRequestState::cases()),
|
||||
"from" => $this->faker->date,
|
||||
"to" => $this->faker->date,
|
||||
"comment" => $this->faker->boolean ? $this->faker->paragraph() : null,
|
||||
];
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Toby\Enums\Role;
|
||||
|
||||
return new class() extends Migration {
|
||||
public function up(): void
|
||||
@@ -15,6 +16,7 @@ return new class() extends Migration {
|
||||
$table->string("last_name");
|
||||
$table->string("email")->unique();
|
||||
$table->string("avatar")->nullable();
|
||||
$table->string("role")->default(Role::EMPLOYEE->value);
|
||||
$table->string("employment_form");
|
||||
$table->date("employment_date");
|
||||
$table->rememberToken();
|
||||
|
@@ -1,27 +0,0 @@
|
||||
<?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::create("personal_access_tokens", function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->morphs("tokenable");
|
||||
$table->string("name");
|
||||
$table->string("token", 64)->unique();
|
||||
$table->text("abilities")->nullable();
|
||||
$table->timestamp("last_used_at")->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists("personal_access_tokens");
|
||||
}
|
||||
};
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Toby\Models\User;
|
||||
|
||||
return new class() extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create("vacation_requests", function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string("name");
|
||||
$table->foreignIdFor(User::class)->constrained()->cascadeOnDelete();
|
||||
$table->string("type");
|
||||
$table->string("state")->nullable();
|
||||
$table->date("from");
|
||||
$table->date("to");
|
||||
$table->text("comment")->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists("vacation_requests");
|
||||
}
|
||||
};
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Toby\Models\User;
|
||||
use Toby\Models\VacationRequest;
|
||||
|
||||
return new class() extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create("vacation_request_activities", function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignIdFor(VacationRequest::class)->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(User::class)->nullable()->constrained()->cascadeOnDelete();
|
||||
$table->string("from")->nullable();
|
||||
$table->string("to");
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists("vacation_request_activities");
|
||||
}
|
||||
};
|
@@ -11,6 +11,7 @@ use Toby\Helpers\PolishHolidaysRetriever;
|
||||
use Toby\Helpers\UserAvatarGenerator;
|
||||
use Toby\Models\User;
|
||||
use Toby\Models\VacationLimit;
|
||||
use Toby\Models\VacationRequest;
|
||||
use Toby\Models\YearPeriod;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
@@ -24,11 +25,14 @@ class DatabaseSeeder extends Seeder
|
||||
{
|
||||
User::unsetEventDispatcher();
|
||||
YearPeriod::unsetEventDispatcher();
|
||||
VacationRequest::unsetEventDispatcher();
|
||||
|
||||
User::factory(9)->create();
|
||||
User::factory([
|
||||
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
||||
])->create();
|
||||
])
|
||||
->hasVacationRequests(5)
|
||||
->create();
|
||||
|
||||
$users = User::all();
|
||||
|
||||
|
Reference in New Issue
Block a user