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
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace Database\Factories;
use App\Models\Category;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Category>
*/
class CategoryFactory extends Factory
{
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$name = fake()->unique()->words(2, true);
return [
'parent_id' => null,
'name' => Str::title($name),
'slug' => Str::slug($name),
'description' => fake()->sentence(),
];
}
public function childOf(Category $parent): static
{
return $this->state(fn () => ['parent_id' => $parent->id]);
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use App\Models\Page;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Page>
*/
class PageFactory extends Factory
{
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$title = fake()->unique()->words(2, true);
return [
'title' => Str::title($title),
'slug' => Str::slug($title),
'body' => implode("\n\n", fake()->paragraphs(3)),
'published' => true,
'show_in_footer' => true,
'order' => 0,
];
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Database\Factories;
use App\Enums\PostStatus;
use App\Models\Category;
use App\Models\Post;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Post>
*/
class PostFactory extends Factory
{
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$title = fake()->unique()->sentence();
$publishedAt = fake()->dateTimeBetween('-6 months', 'now');
return [
'user_id' => User::factory(),
'category_id' => Category::factory(),
'title' => rtrim($title, '.'),
'slug' => Str::slug($title),
'excerpt' => fake()->sentence(20),
'body' => implode("\n\n", fake()->paragraphs(6)),
'status' => PostStatus::Published,
'published_at' => $publishedAt,
'meta_title' => null,
'meta_description' => null,
];
}
public function draft(): static
{
return $this->state(fn () => [
'status' => PostStatus::Draft,
'published_at' => null,
]);
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace Database\Factories;
use App\Models\Tag;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Tag>
*/
class TagFactory extends Factory
{
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$name = fake()->unique()->word();
return [
'name' => $name,
'slug' => Str::slug($name),
];
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace Database\Factories;
use App\Models\Tool;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Tool>
*/
class ToolFactory extends Factory
{
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$name = fake()->unique()->company();
$categories = array_keys(config('tools.categories'));
return [
'name' => $name,
'slug' => Str::slug($name),
'description' => fake()->paragraph(),
'url' => fake()->url(),
'logo_url' => 'https://picsum.photos/seed/'.Str::slug($name).'/200',
'category' => fake()->randomElement($categories),
'subcategory' => fake()->randomElement(['Code Assistants', 'Image Generation', 'Chatbots', 'Automation', null]),
'tags' => fake()->randomElements(['free', 'api', 'open-source', 'freemium', 'chrome-extension'], rand(1, 3)),
'pricing' => fake()->randomElement(['Free', 'Freemium', '$10/month', '$29/month', 'Contact for pricing']),
'features' => fake()->sentences(3),
'views' => fake()->numberBetween(0, 5000),
'clicks' => fake()->numberBetween(0, 500),
'featured' => false,
'approved' => true,
];
}
public function featured(): static
{
return $this->state(fn () => ['featured' => true]);
}
public function pending(): static
{
return $this->state(fn () => ['approved' => false]);
}
}
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->bigInteger('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->bigInteger('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,59 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedSmallInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->string('connection');
$table->string('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
$table->index(['connection', 'queue', 'failed_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->foreignId('parent_id')->nullable()->constrained('categories')->nullOnDelete();
$table->string('name');
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->string('meta_title')->nullable();
$table->string('meta_description')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('categories');
}
};
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tags', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tags');
}
};
@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
$table->string('title');
$table->string('slug')->unique();
$table->text('excerpt')->nullable();
$table->longText('body');
$table->string('featured_image')->nullable();
$table->string('status')->default('draft');
$table->timestamp('published_at')->nullable();
$table->string('meta_title')->nullable();
$table->string('meta_description')->nullable();
$table->timestamps();
$table->index(['status', 'published_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('posts');
}
};
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('post_tag', function (Blueprint $table) {
$table->foreignId('post_id')->constrained()->cascadeOnDelete();
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
$table->primary(['post_id', 'tag_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('post_tag');
}
};
@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tools', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->text('description');
$table->string('url');
$table->string('logo_url')->nullable();
$table->string('category');
$table->string('subcategory')->nullable();
$table->json('tags')->nullable();
$table->string('pricing')->nullable();
$table->json('features')->nullable();
$table->unsignedInteger('views')->default(0);
$table->unsignedInteger('clicks')->default(0);
$table->boolean('featured')->default(false);
$table->boolean('approved')->default(false);
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->timestamps();
$table->index(['category', 'subcategory']);
$table->index(['approved', 'featured']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tools');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('pages', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('slug')->unique();
$table->longText('body');
$table->string('meta_title')->nullable();
$table->string('meta_description')->nullable();
$table->boolean('published')->default(true);
$table->boolean('show_in_footer')->default(true);
$table->unsignedSmallInteger('order')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('pages');
}
};
+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,
]);
}
}