Snapshot of main at 9f39a6e1e (2026-11-02)

This commit is contained in:
Ronald Huynen committed 2026-11-02 10:41:47 +01:00
commit 6ccf1792d7
2580 files changed
+1040202

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
<?php
namespace Database\Seeders;
use App\Models\Account;
use App\Models\Locations\Location;
use App\Models\User;
use Illuminate\Database\Seeder;
class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$usersCount = max((int)$this->command->ask('How many fake users would you like?', 200), 0);
$cities = [
305, // The Hague is used more frequent
305, // The Hague
305, // The Hague
305, // The Hague
300, // Delft
330, // Rijswijk
342, // Zoetermeer
345, // Brussels is used slightly more frequent
345, // Brussels
346, // Antwerp
];
User::factory()->count($usersCount)
->has(Account::factory()->state(['name' => 'Personal Account']))
->create()
->each(
function ($user) use ($cities) {
// Create a location with a random city_id for each user
Location::factory()->create([
'locatable_type' => User::class, // This specifies the relation is with User
'locatable_id' => $user->id,
'city_id' => collect($cities)->random(),
]);
}
);
}
}