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

DatabaseSeeder.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Database\Seeders;
  3. use App\Models\Company;
  4. use App\Models\User;
  5. use Database\Factories\CompanyFactory;
  6. use Illuminate\Database\Seeder;
  7. class DatabaseSeeder extends Seeder
  8. {
  9. /**
  10. * Seed the application's database.
  11. */
  12. public function run(): void
  13. {
  14. // Create a single admin user and their personal company
  15. $user = User::factory()
  16. ->withPersonalCompany(function (CompanyFactory $factory) {
  17. return $factory
  18. ->state([
  19. 'name' => 'ERPSAAS',
  20. ])
  21. ->withTransactions()
  22. ->withOfferings()
  23. ->withClients()
  24. ->withVendors()
  25. ->withInvoices(50)
  26. ->withRecurringInvoices()
  27. ->withEstimates(50)
  28. ->withBills(50);
  29. })
  30. ->create([
  31. 'name' => 'Admin',
  32. 'email' => 'admin@erpsaas.com',
  33. 'password' => bcrypt('password'),
  34. 'current_company_id' => 1, // Assuming this will be the ID of the created company
  35. ]);
  36. $additionalCompanies = [
  37. ['name' => 'European Retail GmbH', 'country' => 'DE', 'currency' => 'EUR', 'locale' => 'en'],
  38. ['name' => 'UK Services Ltd', 'country' => 'GB', 'currency' => 'GBP', 'locale' => 'en'],
  39. ['name' => 'Canadian Manufacturing Inc', 'country' => 'CA', 'currency' => 'CAD', 'locale' => 'en'],
  40. ['name' => 'Australian Hospitality Pty', 'country' => 'AU', 'currency' => 'AUD', 'locale' => 'en'],
  41. ];
  42. foreach ($additionalCompanies as $companyData) {
  43. Company::factory()
  44. ->state([
  45. 'name' => $companyData['name'],
  46. 'user_id' => $user->id,
  47. 'personal_company' => false,
  48. ])
  49. ->withCompanyProfile($companyData['country'])
  50. ->withCompanyDefaults($companyData['currency'], $companyData['locale'])
  51. ->withTransactions(100)
  52. ->withOfferings()
  53. ->withClients()
  54. ->withVendors()
  55. ->withInvoices(20)
  56. ->withRecurringInvoices()
  57. ->withEstimates(15)
  58. ->withBills(15)
  59. ->create();
  60. }
  61. }
  62. }