From b574745338195aac52d075efb689209b0d02da44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Pocrnji=C4=8D?= Date: Tue, 30 Sep 2025 00:28:04 +0200 Subject: [PATCH] seed for account types --- database/seeders/AccountTypeSeeder.php | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 database/seeders/AccountTypeSeeder.php diff --git a/database/seeders/AccountTypeSeeder.php b/database/seeders/AccountTypeSeeder.php new file mode 100644 index 0000000..c44d1b3 --- /dev/null +++ b/database/seeders/AccountTypeSeeder.php @@ -0,0 +1,51 @@ + 1, 'name' => 'Default', 'description' => 'Default account type', 'created_at' => $now, 'updated_at' => $now], + ['id' => 2, 'name' => 'Primary', 'description' => 'Primary account', 'created_at' => $now, 'updated_at' => $now], + ['id' => 3, 'name' => 'Secondary', 'description' => 'Secondary account', 'created_at' => $now, 'updated_at' => $now], + ['id' => 4, 'name' => 'Savings', 'description' => 'Savings account', 'created_at' => $now, 'updated_at' => $now], + ['id' => 5, 'name' => 'Checking', 'description' => 'Checking account', 'created_at' => $now, 'updated_at' => $now], + ['id' => 6, 'name' => 'Credit', 'description' => 'Credit account', 'created_at' => $now, 'updated_at' => $now], + ['id' => 7, 'name' => 'Loan', 'description' => 'Loan account', 'created_at' => $now, 'updated_at' => $now], + ['id' => 8, 'name' => 'Other', 'description' => 'Other account type', 'created_at' => $now, 'updated_at' => $now], + ]; + DB::table('account_types')->insert($rows); + + return; + } + + // If table already has data, ensure the basics exist (idempotent, no explicit IDs) + $names = [ + 'Default' => 'Default account type', + 'Primary' => 'Primary account', + 'Secondary' => 'Secondary account', + 'Savings' => 'Savings account', + 'Checking' => 'Checking account', + 'Credit' => 'Credit account', + 'Loan' => 'Loan account', + 'Other' => 'Other account type', + ]; + + foreach ($names as $name => $desc) { + AccountType::updateOrCreate( + ['name' => $name], + ['description' => $desc] + ); + } + } +}