PromptVault/database/seeders/PromptSeeder.php

59 lines
1.9 KiB
PHP
Raw Normal View History

2026-10-26 20:12:16 +00:00
<?php
namespace Database\Seeders;
use App\Models\Prompt;
use App\Models\Tag;
use Illuminate\Database\Seeder;
class PromptSeeder extends Seeder
{
public function run(): void
{
Prompt::query()->delete();
Tag::query()->delete();
$this->create('Code Reviewer', 'Review a diff and surface bugs, risks, and style issues.',
"You are a senior software engineer. Review this {{language}} diff and report:\n\n1. Bugs or logic errors\n2. Security concerns\n3. Readability suggestions\n\nDiff:\n{{diff}}",
['coding', 'general'],
isFavorite: true,
);
$this->create('Three-Bullet Summarizer', 'Turn any text into exactly three bullets.',
'Summarize the following text in exactly three bullet points. Keep each bullet under 20 words.\n\nText:\n{{content}}',
['general'],
);
$this->create('Marketing Hook Generator', 'Five short hooks for a product and audience.',
'Write five short marketing hooks (under 12 words each) for {{product}}, targeting {{audience}}.',
['marketing', 'writing'],
);
$this->create('Regex Explainer', 'Explain a regular expression in plain language.',
'Explain this regular expression in plain language, then give two example inputs that match and two that do not:\n\n{{regex}}',
['coding'],
);
}
/**
* @param list<string> $tags
*/
private function create(string $name, string $description, string $body, array $tags, bool $isFavorite = false): void
{
$prompt = Prompt::query()->create([
'name' => $name,
'description' => $description,
'body' => $body,
'is_favorite' => $isFavorite,
]);
$ids = array_map(
fn (string $tag) => Tag::query()->firstOrCreate(['name' => $tag])->id,
$tags
);
$prompt->tags()->sync($ids);
}
}