This commit is contained in:
Adrian Hopek
2022-01-24 10:23:08 +01:00
parent 75889a16e6
commit 62fc1e1ca9
14 changed files with 51 additions and 37 deletions

View File

@@ -11,7 +11,7 @@ use Toby\Models\YearPeriod;
return new class() extends Migration {
public function up(): void
{
Schema::create('vacation_limits', function (Blueprint $table): void {
Schema::create("vacation_limits", function (Blueprint $table): void {
$table->id();
$table->foreignIdFor(User::class)->constrained()->cascadeOnDelete();
$table->foreignIdFor(YearPeriod::class)->constrained()->cascadeOnDelete();
@@ -23,6 +23,6 @@ return new class() extends Migration {
public function down(): void
{
Schema::dropIfExists('vacation_limits');
Schema::dropIfExists("vacation_limits");
}
};

View File

@@ -14,8 +14,9 @@ use Toby\Models\YearPeriod;
class DatabaseSeeder extends Seeder
{
public function __construct(protected UserAvatarGenerator $avatarGenerator)
{
public function __construct(
protected UserAvatarGenerator $avatarGenerator,
) {
}
public function run(): void
@@ -23,7 +24,7 @@ class DatabaseSeeder extends Seeder
User::unsetEventDispatcher();
YearPeriod::unsetEventDispatcher();
User::factory(14)->create();
User::factory(9)->create();
User::factory([
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
])->create();
@@ -35,11 +36,17 @@ class DatabaseSeeder extends Seeder
YearPeriod::factory()
->count(3)
->sequence(
["year" => Carbon::now()->year - 1],
["year" => Carbon::now()->year],
["year" => Carbon::now()->year + 1],
[
"year" => Carbon::now()->year - 1,
],
[
"year" => Carbon::now()->year,
],
[
"year" => Carbon::now()->year + 1,
],
)
->afterCreating(function (YearPeriod $yearPeriod) use ($users) {
->afterCreating(function (YearPeriod $yearPeriod) use ($users): void {
foreach ($users as $user) {
VacationLimit::factory()
->for($yearPeriod)
@@ -47,7 +54,7 @@ class DatabaseSeeder extends Seeder
->create();
}
})
->create();
->create();
}
protected function generateAvatarsForUsers(Collection $users): void