22
33namespace 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 ;
95use Illuminate \Database \Seeder ;
10- use Illuminate \Support \Facades \ Hash ;
6+ use Illuminate \Support \Str ;
117
128class 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