This commit is contained in:
ct
2025-08-10 22:21:19 +08:00
parent 1b8bb22c4e
commit dd4cbf76ad
2 changed files with 4 additions and 7 deletions

View File

@@ -0,0 +1,29 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
class SingleUserSeeder extends Seeder
{
public function run(): void
{
if (User::exists()) {
$this->command->error("Users already exist! This seeder can only be run once.");
return;
}
$user = User::create([
'name' => 'Crawlshot API User',
'email' => 'api@crawlshot.test',
'password' => bcrypt('password')
]);
$token = $user->createToken('crawlshot-api')->plainTextToken;
$this->command->info("User created: {$user->email}");
$this->command->info("API Token: {$token}");
$this->command->line("Use this token in Authorization header: Bearer {$token}");
}
}