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

DatabaseSeeder.php 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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(250)
  22. ->withOfferings()
  23. ->withClients()
  24. ->withVendors()
  25. ->withInvoices(30)
  26. ->withRecurringInvoices()
  27. ->withEstimates(30)
  28. ->withBills(30);
  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. // Only use en locale for now
  37. $additionalCompanies = [
  38. ['name' => 'British Crown Analytics', 'country' => 'GB', 'currency' => 'GBP', 'locale' => 'en'],
  39. ['name' => 'Swiss Precision Group', 'country' => 'CH', 'currency' => 'CHF', 'locale' => 'en'],
  40. ['name' => 'Tokyo Future Technologies', 'country' => 'JP', 'currency' => 'JPY', 'locale' => 'en'],
  41. ['name' => 'Sydney Harbor Systems', 'country' => 'AU', 'currency' => 'AUD', 'locale' => 'en'],
  42. ['name' => 'Mumbai Software Services', 'country' => 'IN', 'currency' => 'INR', 'locale' => 'en'],
  43. ['name' => 'Singapore Digital Hub', 'country' => 'SG', 'currency' => 'SGD', 'locale' => 'en'],
  44. ['name' => 'Dubai Business Consulting', 'country' => 'AE', 'currency' => 'AED', 'locale' => 'en'],
  45. ];
  46. foreach ($additionalCompanies as $companyData) {
  47. Company::factory()
  48. ->state([
  49. 'name' => $companyData['name'],
  50. 'user_id' => $user->id,
  51. 'personal_company' => false,
  52. ])
  53. ->withCompanyProfile($companyData['country'])
  54. ->withCompanyDefaults($companyData['currency'], $companyData['locale'])
  55. ->withTransactions(100)
  56. ->withOfferings()
  57. ->withClients()
  58. ->withVendors()
  59. ->withInvoices(15)
  60. ->withRecurringInvoices()
  61. ->withEstimates(15)
  62. ->withBills(15)
  63. ->create();
  64. }
  65. }
  66. }