b2in/packages/flux-cms/core/database/seeders/CmsContentSeeder.php
2025-10-20 17:50:35 +02:00

175 lines
6.9 KiB
PHP

<?php
namespace FluxCms\Core\Database\Seeders;
use Illuminate\Database\Seeder;
use FluxCms\Core\Models\Page;
use FluxCms\Core\Models\BlogPost;
class CmsContentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$this->createSamplePages();
$this->createSampleBlogPosts();
}
/**
* Create sample pages
*/
protected function createSamplePages(): void
{
// Homepage
$homepage = Page::create([
'domain_key' => 'default',
'title' => [
'de' => 'Willkommen auf unserer Website',
'en' => 'Welcome to our Website'
],
'slug' => [
'de' => '/',
'en' => '/'
],
'meta_description' => [
'de' => 'Willkommen auf unserer modernen Website, erstellt mit Flux CMS.',
'en' => 'Welcome to our modern website, built with Flux CMS.'
],
'meta_keywords' => [
'de' => 'Website, CMS, Flux CMS, Laravel',
'en' => 'Website, CMS, Flux CMS, Laravel'
],
'is_published' => true,
'published_at' => now(),
]);
// About page
$aboutPage = Page::create([
'domain_key' => 'default',
'title' => [
'de' => 'Über uns',
'en' => 'About us'
],
'slug' => [
'de' => '/ueber-uns',
'en' => '/about'
],
'meta_description' => [
'de' => 'Erfahren Sie mehr über unser Unternehmen und unsere Mission.',
'en' => 'Learn more about our company and our mission.'
],
'is_published' => true,
'published_at' => now(),
]);
// Contact page
$contactPage = Page::create([
'domain_key' => 'default',
'title' => [
'de' => 'Kontakt',
'en' => 'Contact'
],
'slug' => [
'de' => '/kontakt',
'en' => '/contact'
],
'meta_description' => [
'de' => 'Kontaktieren Sie uns für weitere Informationen.',
'en' => 'Contact us for more information.'
],
'is_published' => true,
'published_at' => now(),
]);
$this->command->info('Sample pages created successfully!');
}
/**
* Create sample blog posts
*/
protected function createSampleBlogPosts(): void
{
$posts = [
[
'title' => [
'de' => 'Willkommen bei Flux CMS',
'en' => 'Welcome to Flux CMS'
],
'slug' => [
'de' => 'willkommen-bei-flux-cms',
'en' => 'welcome-to-flux-cms'
],
'excerpt' => [
'de' => 'Flux CMS ist ein modernes, komponentenbasiertes Content Management System für Laravel.',
'en' => 'Flux CMS is a modern, component-based Content Management System for Laravel.'
],
'content' => [
'de' => '<p>Flux CMS revolutioniert die Art, wie Sie Inhalte verwalten. Mit seiner einzigartigen "Code-as-Schema" Philosophie definieren Sie Inhaltsstrukturen direkt in PHP-Komponenten.</p><p>Dies bietet beispiellose Flexibilität und eine hervorragende Entwicklererfahrung.</p>',
'en' => '<p>Flux CMS revolutionizes the way you manage content. With its unique "Code-as-Schema" philosophy, you define content structures directly in PHP components.</p><p>This offers unprecedented flexibility and an excellent developer experience.</p>'
],
'category' => 'News',
'tags' => ['CMS', 'Laravel', 'Flux'],
'is_published' => true,
'is_featured' => true,
'published_at' => now()->subDays(1),
],
[
'title' => [
'de' => 'Multi-Domain Support',
'en' => 'Multi-Domain Support'
],
'slug' => [
'de' => 'multi-domain-support',
'en' => 'multi-domain-support'
],
'excerpt' => [
'de' => 'Verwalten Sie mehrere Websites von einer Installation aus.',
'en' => 'Manage multiple websites from one installation.'
],
'content' => [
'de' => '<p>Mit Flux CMS können Sie mehrere Domains von einer einzigen Installation aus verwalten. Jede Domain kann ihre eigenen Inhalte, Designs und Einstellungen haben.</p>',
'en' => '<p>With Flux CMS, you can manage multiple domains from a single installation. Each domain can have its own content, designs, and settings.</p>'
],
'category' => 'Features',
'tags' => ['Multi-Domain', 'Features'],
'is_published' => true,
'is_featured' => false,
'published_at' => now()->subDays(2),
],
[
'title' => [
'de' => 'Komponenten-First Architektur',
'en' => 'Component-First Architecture'
],
'slug' => [
'de' => 'komponenten-first-architektur',
'en' => 'component-first-architecture'
],
'excerpt' => [
'de' => 'Bauen Sie Seiten aus wiederverwendbaren Livewire-Komponenten.',
'en' => 'Build pages from reusable Livewire components.'
],
'content' => [
'de' => '<p>Die Komponenten-First Architektur von Flux CMS ermöglicht es Ihnen, komplexe Seiten aus kleinen, wiederverwendbaren Komponenten zu erstellen.</p><p>Jede Komponente kann ihre eigenen Felder und Validierungsregeln definieren.</p>',
'en' => '<p>The component-first architecture of Flux CMS allows you to create complex pages from small, reusable components.</p><p>Each component can define its own fields and validation rules.</p>'
],
'category' => 'Architecture',
'tags' => ['Components', 'Livewire', 'Architecture'],
'is_published' => true,
'is_featured' => false,
'published_at' => now()->subDays(3),
],
];
foreach ($posts as $postData) {
BlogPost::create(array_merge($postData, [
'domain_key' => 'default',
'author_id' => 1, // Assuming user ID 1 exists
]));
}
$this->command->info('Sample blog posts created successfully!');
}
}