38 lines
999 B
PHP
38 lines
999 B
PHP
<?php
|
|
|
|
/**
|
|
* BlogCategoriesSeed.php
|
|
*
|
|
* Author: Funky Waddle
|
|
* Date: 2026-09-06
|
|
*
|
|
* Purpose: Seeds the mandatory "Uncategorized" `blog_categories` row (per
|
|
* `plugins_architecture.notes` in APP.yaml - "A 'Uncategorized' blog category
|
|
* will exist"). Every blog post must belong to at least one category, and
|
|
* `BlogPostService` falls back to this one when none is explicitly chosen.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Phinx\Seed\AbstractSeed;
|
|
|
|
final class BlogCategoriesSeed extends AbstractSeed
|
|
{
|
|
public function run(): void
|
|
{
|
|
$exists = $this->fetchRow(
|
|
"SELECT id FROM blog_categories WHERE slug = 'uncategorized'",
|
|
);
|
|
|
|
if ($exists) {
|
|
return;
|
|
}
|
|
|
|
$this->table('blog_categories')->insert([
|
|
'name' => 'Uncategorized',
|
|
'slug' => 'uncategorized',
|
|
'description' => 'Default category for blog posts that have not been assigned a more specific category.',
|
|
])->saveData();
|
|
}
|
|
}
|