Add Blog module to Citrus Platform: Created Blog resource with CRUD pages, schemas, and models. Implemented localization for English and Turkish, ensuring consistent user experience. Added migrations for blog categories, posts, and comments, including soft delete functionality. Enhanced table and form structures for better organization and usability.

This commit is contained in:
Ümit Tunç
2025-09-29 10:20:40 -03:00
parent a2087e7178
commit 79a1f5b746
20 changed files with 1145 additions and 70 deletions
@@ -0,0 +1,36 @@
<?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('blog_categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->string('color', 7)->default('#3B82F6'); // Hex color
$table->integer('sort_order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->softDeletes();
$table->index(['is_active', 'sort_order']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('blog_categories');
}
};
@@ -0,0 +1,47 @@
<?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('blogs', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('slug')->unique();
$table->longText('content');
$table->text('excerpt')->nullable();
$table->string('meta_title')->nullable();
$table->text('meta_description')->nullable();
$table->enum('status', ['draft', 'published', 'archived'])->default('draft');
$table->string('featured_image')->nullable();
$table->timestamp('published_at')->nullable();
$table->foreignId('author_id')->constrained('users')->onDelete('cascade');
$table->foreignId('category_id')->nullable()->constrained('blog_categories')->onDelete('set null');
$table->json('tags')->nullable();
$table->integer('view_count')->default(0);
$table->boolean('is_featured')->default(false);
$table->boolean('allow_comments')->default(true);
$table->timestamps();
$table->softDeletes();
$table->index(['status', 'published_at']);
$table->index(['category_id', 'status']);
$table->index(['is_featured', 'status']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('blogs');
}
};
@@ -0,0 +1,39 @@
<?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('blog_comments', function (Blueprint $table) {
$table->id();
$table->foreignId('blog_id')->constrained('blogs')->onDelete('cascade');
$table->string('name');
$table->string('email');
$table->text('content');
$table->enum('status', ['pending', 'approved', 'spam', 'rejected'])->default('pending');
$table->foreignId('parent_id')->nullable()->constrained('blog_comments')->onDelete('cascade');
$table->string('ip_address')->nullable();
$table->text('user_agent')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['blog_id', 'status']);
$table->index(['status', 'created_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('blog_comments');
}
};
@@ -0,0 +1,34 @@
<?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::table('blogs', function (Blueprint $table) {
// Eğer deleted_at sütunu yoksa ekle
if (!Schema::hasColumn('blogs', 'deleted_at')) {
$table->softDeletes();
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('blogs', function (Blueprint $table) {
// deleted_at sütununu sil
if (Schema::hasColumn('blogs', 'deleted_at')) {
$table->dropSoftDeletes();
}
});
}
};