You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserCompanySeeder.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 UserCompanySeeder extends Seeder
  8. {
  9. /**
  10. * Run the database seeds.
  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' => 'Akaun',
  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@akaun.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' => 'British Crown Analytics', 'country' => 'GB', 'currency' => 'GBP', 'locale' => 'en'],
  38. ['name' => 'Berlin Tech Solutions', 'country' => 'DE', 'currency' => 'EUR', 'locale' => 'en'],
  39. ['name' => 'Mumbai Software Services', 'country' => 'IN', 'currency' => 'INR', 'locale' => 'en'],
  40. ];
  41. foreach ($additionalCompanies as $companyData) {
  42. Company::factory()
  43. ->state([
  44. 'name' => $companyData['name'],
  45. 'user_id' => $user->id,
  46. 'personal_company' => false,
  47. ])
  48. ->withCompanyProfile($companyData['country'])
  49. ->withCompanyDefaults($companyData['currency'], $companyData['locale'])
  50. ->withTransactions(50)
  51. ->withOfferings()
  52. ->withClients()
  53. ->withVendors()
  54. ->withInvoices()
  55. ->withRecurringInvoices()
  56. ->withEstimates()
  57. ->withBills()
  58. ->create();
  59. }
  60. }
  61. }