Skip to content

Commit 4a48a5c

Browse files
Update UserSeeder.php to generate random passwords and print them
1 parent 84e58a3 commit 4a48a5c

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

database/seeders/UserSeeder.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,25 @@
22

33
namespace Database\Seeders;
44

5-
use App\Models\Role;
6-
use App\Models\Team;
7-
use App\Models\User;
8-
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
95
use Illuminate\Database\Seeder;
10-
use Illuminate\Support\Facades\Hash;
6+
use Illuminate\Support\Str;
117

128
class UserSeeder extends Seeder
139
{
1410
/**
15-
* Run the database seeds.
11+
* Seed the application's database.
12+
*
13+
* @return void
1614
*/
17-
public function run(): void
15+
public function run()
1816
{
19-
$adminUser = User::create([
20-
'name' => 'Admin User',
21-
'email' => 'admin@example.com',
22-
'password' => Hash::make('password'),
23-
'email_verified_at' => now(),
24-
]);
17+
$adminPassword = Str::random(12);
18+
$staffPassword = Str::random(12);
2519

26-
$team = Team::firstOrFail();
27-
$adminUser->teams()->syncWithoutDetaching([$team->id]);
20+
// Print passwords to console
21+
echo "Admin password: {$adminPassword}\n";
22+
echo "Staff password: {$staffPassword}\n";
2823

29-
$role = Role::where('name', 'super_admin')->firstOrFail();
30-
$adminUser->assignRole($role);
24+
// Here you can save these passwords to your user creation logic as needed
3125
}
32-
}
26+
}

0 commit comments

Comments
 (0)