Commit 7c00af9
authored
refactor: Use firstOrCreate for user seed/test data (#158)
Updates the user creation logic to use the Eloquent `firstOrCreate` method instead of `factory()->create`.
This change achieves two main goals:
1. **Idempotency and Reliability:** Prevents the code from failing on repeated execution (e.g., when running seeders or tests multiple times) due to the database's unique constraint on the `email` column. `firstOrCreate` ensures the user is only created once.
2. **Complete User Data:** Includes essential attributes like a hashed password (`Hash::make('password')`) and sets `email_verified_at` to `now()`, making the test user fully functional for immediate authentication and verification checks.1 parent 3d175f0 commit 7c00af9
1 file changed
+8
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
0 commit comments