30 lines
783 B
PHP
30 lines
783 B
PHP
<?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}");
|
|
}
|
|
}
|