first commit

This commit is contained in:
Doar Mihai
2026-08-08 18:03:29 +03:00
commit df2128ebff
183 changed files with 18719 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
<?php
namespace Database\Seeders;
use App\Models\Category;
use App\Models\Page;
use App\Models\Post;
use App\Models\Tag;
use App\Models\Tool;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
$author = User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
$tags = Tag::factory(8)->create();
$topLevel = Category::factory(3)->create();
$topLevel->each(function (Category $category) {
Category::factory(2)->childOf($category)->create();
});
$allCategories = Category::all();
Post::factory(20)
->recycle($author)
->state(fn () => ['category_id' => $allCategories->random()->id])
->create()
->each(fn (Post $post) => $post->tags()->attach($tags->random(rand(1, 3))->pluck('id')));
Post::factory(3)
->draft()
->recycle($author)
->state(fn () => ['category_id' => $allCategories->random()->id])
->create();
Tool::factory(4)->featured()->recycle($author)->create();
Tool::factory(20)->recycle($author)->create();
Tool::factory(3)->pending()->recycle($author)->create();
Page::factory()->create([
'title' => 'About',
'slug' => 'about',
'body' => "We're a small team writing about AI tools, workflows, and everything in between.",
'order' => 1,
]);
Page::factory()->create([
'title' => 'Contact',
'slug' => 'contact',
'body' => 'Questions or feedback? Reach us at [hello@example.com](mailto:hello@example.com).',
'order' => 2,
]);
Page::factory()->create([
'title' => 'Privacy Policy',
'slug' => 'privacy-policy',
'body' => 'We respect your privacy and only collect the minimum data needed to run this site.',
'order' => 3,
]);
}
}