您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DatabaseSeeder.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Database\Seeders;
  3. use App\Models\User;
  4. use Database\Factories\CompanyFactory;
  5. use Illuminate\Database\Seeder;
  6. class DatabaseSeeder extends Seeder
  7. {
  8. /**
  9. * Seed the application's database.
  10. */
  11. public function run(): void
  12. {
  13. // Create a single admin user and their personal company
  14. $adminUser = User::factory()
  15. ->withPersonalCompany(function (CompanyFactory $factory) {
  16. return $factory->withTransactions();
  17. })
  18. ->create([
  19. 'name' => 'Admin',
  20. 'email' => 'admin@gmail.com',
  21. 'password' => bcrypt('password'),
  22. 'current_company_id' => 1, // Assuming this will be the ID of the created company
  23. 'created_at' => now(),
  24. ]);
  25. // Optionally, set additional properties or create related entities specific to this company
  26. $adminUser->ownedCompanies->first()->update([
  27. 'name' => 'ERPSAAS',
  28. 'created_at' => now(),
  29. ]);
  30. }
  31. }