領収証発行サービス
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.

63 lines
1.9KB

  1. <?php
  2. namespace Database\Seeders;
  3. use App\Codes\Custom;
  4. use App\Codes\UserRole;
  5. use App\Models\Contract;
  6. use App\Models\User;
  7. use Illuminate\Database\Seeder;
  8. class TestUserSeeder extends Seeder
  9. {
  10. /**
  11. * Run the database seeds.
  12. */
  13. public function run(): void
  14. {
  15. // $contract = Contract::factory()->create([
  16. // Contract::COL_NAME_NAME => 'テスト用契約'
  17. // ]);
  18. $emails = [
  19. ['normal@aa.com', UserRole::NORMAL_ADMIN],
  20. ['contract@aa.com', UserRole::CONTRACT_ADMIN],
  21. ['admin@aa.com', UserRole::SUPER_ADMIN],
  22. ];
  23. foreach ($emails as [$email, $role]) {
  24. if (!User::whereEmail($email)->exists()) {
  25. // User::factory()->for($contract)->create([
  26. User::factory()->create([
  27. User::COL_NAME_EMAIL => $email,
  28. User::COL_NAME_ROLE => $role,
  29. User::COL_NAME_NAME => $email . "太郎",
  30. ]);
  31. }
  32. }
  33. $contract = Contract::factory()->create([
  34. Contract::COL_NAME_NAME => 'テスト用契約 HT',
  35. Contract::COL_NAME_CUSTOM => Custom::HELLO_TECHNO,
  36. ]);
  37. $email = 'hello@aa.com';
  38. if (!User::whereEmail($email)->exists()) {
  39. User::factory()->for($contract)->create([
  40. User::COL_NAME_EMAIL => $email,
  41. User::COL_NAME_ROLE => UserRole::NORMAL_ADMIN,
  42. User::COL_NAME_NAME => $email . "太郎",
  43. ]);
  44. }
  45. $email = 'hello-admin@aa.com';
  46. if (!User::whereEmail($email)->exists()) {
  47. User::factory()->for($contract)->create([
  48. User::COL_NAME_EMAIL => $email,
  49. User::COL_NAME_ROLE => UserRole::CONTRACT_ADMIN,
  50. User::COL_NAME_NAME => $email . "太郎",
  51. ]);
  52. }
  53. }
  54. }