Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Commit

Permalink
Generate admin user in Database Seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
kkamara committed Aug 4, 2023
1 parent 8ebbfd6 commit 7b13799
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;

class DatabaseSeeder extends Seeder
{
Expand All @@ -12,11 +13,15 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// \App\Models\User::factory(10)->create();

// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
$email = 'admin@example.com';
if (
null !== User::where(
'email', $email
)->first()
) {
return;
}
User::factory()->count(1)
->create(compact('email'));
}
}

0 comments on commit 7b13799

Please sign in to comment.