Initial baseline: LaraBlog core with plugin commerce surface.
Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
@@ -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->integer('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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->unsignedTinyInteger('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->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('settings.repositories.database.table') ?? 'settings', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
|
||||
$table->string('group');
|
||||
$table->string('name');
|
||||
$table->boolean('locked')->default(false);
|
||||
$table->json('payload');
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['group', 'name']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,134 @@
|
||||
<?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
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), Exception::class, 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
|
||||
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||
// $table->engine('InnoDB');
|
||||
$table->bigIncrements('id'); // permission id
|
||||
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||
// $table->engine('InnoDB');
|
||||
$table->bigIncrements('id'); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('log_name')->nullable();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject', 'subject');
|
||||
$table->nullableMorphs('causer', 'causer');
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('log_name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddEventColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->string('event')->nullable()->after('subject_type');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('event');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddBatchUuidColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->uuid('batch_uuid')->nullable()->after('properties');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('batch_uuid');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('display_order')->default(0);
|
||||
$table->unsignedInteger('articles_count')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('articles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('category_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('title');
|
||||
$table->longText('content');
|
||||
$table->string('content_format', 16)->default('html');
|
||||
$table->string('description')->nullable();
|
||||
$table->string('keywords')->nullable();
|
||||
$table->timestamp('published_at')->nullable();
|
||||
$table->unsignedBigInteger('views')->default(0);
|
||||
$table->unsignedInteger('comments_count')->default(0);
|
||||
$table->string('slug')->nullable()->unique();
|
||||
$table->boolean('stick')->default(false);
|
||||
$table->boolean('visible')->default(true);
|
||||
$table->boolean('close_comment')->default(false);
|
||||
$table->string('read_password')->nullable();
|
||||
$table->text('ai_summary')->nullable();
|
||||
$table->json('ai_suggestions')->nullable();
|
||||
$table->json('legacy_attachments')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['visible', 'published_at']);
|
||||
$table->index('category_id');
|
||||
});
|
||||
|
||||
Schema::create('comments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('article_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('author');
|
||||
$table->string('url')->nullable();
|
||||
$table->text('content');
|
||||
$table->string('ip', 45)->nullable();
|
||||
$table->string('moderation_status')->default('pending');
|
||||
$table->timestamp('published_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('tags', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->unsignedInteger('use_count')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('article_tag', function (Blueprint $table) {
|
||||
$table->foreignId('article_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
|
||||
|
||||
$table->unique(['article_id', 'tag_id']);
|
||||
});
|
||||
|
||||
Schema::create('attachments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('article_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('disk')->default('attachments');
|
||||
$table->string('path');
|
||||
$table->string('thumb_path')->nullable();
|
||||
$table->string('filename');
|
||||
$table->string('mime')->nullable();
|
||||
$table->unsignedBigInteger('size')->default(0);
|
||||
$table->string('checksum')->nullable();
|
||||
$table->string('visibility')->default('public');
|
||||
$table->string('legacy_filepath')->nullable();
|
||||
$table->timestamp('synced_at')->nullable();
|
||||
$table->unsignedBigInteger('downloads')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('legacy_filepath');
|
||||
});
|
||||
|
||||
Schema::create('links', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('url');
|
||||
$table->text('note')->nullable();
|
||||
$table->unsignedInteger('display_order')->default(0);
|
||||
$table->boolean('visible')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('stylevars', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->text('value')->nullable();
|
||||
$table->boolean('visible')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('plugins', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->string('version')->default('1.0.0');
|
||||
$table->boolean('enabled')->default(false);
|
||||
$table->string('path');
|
||||
$table->json('config')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('username')->nullable()->unique()->after('name');
|
||||
$table->string('password_legacy')->nullable()->after('password');
|
||||
$table->string('url')->nullable()->after('password_legacy');
|
||||
$table->unsignedInteger('login_count')->default(0)->after('url');
|
||||
$table->string('login_ip', 45)->nullable()->after('login_count');
|
||||
$table->timestamp('login_at')->nullable()->after('login_ip');
|
||||
$table->string('reg_ip', 45)->nullable()->after('login_at');
|
||||
$table->timestamp('last_post_at')->nullable()->after('reg_ip');
|
||||
|
||||
$table->string('email')->nullable()->change();
|
||||
$table->string('password')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'username',
|
||||
'password_legacy',
|
||||
'url',
|
||||
'login_count',
|
||||
'login_ip',
|
||||
'login_at',
|
||||
'reg_ip',
|
||||
'last_post_at',
|
||||
]);
|
||||
});
|
||||
|
||||
Schema::dropIfExists('plugins');
|
||||
Schema::dropIfExists('stylevars');
|
||||
Schema::dropIfExists('links');
|
||||
Schema::dropIfExists('attachments');
|
||||
Schema::dropIfExists('article_tag');
|
||||
Schema::dropIfExists('tags');
|
||||
Schema::dropIfExists('comments');
|
||||
Schema::dropIfExists('articles');
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::dropIfExists('trackbacks');
|
||||
|
||||
Schema::table('articles', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('articles', 'trackbacks_count')) {
|
||||
$table->dropColumn('trackbacks_count');
|
||||
}
|
||||
if (Schema::hasColumn('articles', 'close_trackback')) {
|
||||
$table->dropColumn('close_trackback');
|
||||
}
|
||||
if (! Schema::hasColumn('articles', 'slug')) {
|
||||
$table->string('slug')->nullable()->unique()->after('keywords');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('articles', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('articles', 'slug')) {
|
||||
$table->dropColumn('slug');
|
||||
}
|
||||
$table->unsignedInteger('trackbacks_count')->default(0);
|
||||
$table->boolean('close_trackback')->default(false);
|
||||
});
|
||||
|
||||
Schema::create('trackbacks', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('article_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('title');
|
||||
$table->text('excerpt')->nullable();
|
||||
$table->string('url');
|
||||
$table->string('blog_name')->nullable();
|
||||
$table->string('ip', 45)->nullable();
|
||||
$table->boolean('visible')->default(false);
|
||||
$table->timestamp('published_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('articles', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('articles', 'content_format')) {
|
||||
$table->string('content_format', 16)->default('html')->after('content');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('articles', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('articles', 'content_format')) {
|
||||
$table->dropColumn('content_format');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Phase-2 placeholders for auto/generated cover images.
|
||||
* No generation pipeline in phase 1 — queue/scripts will fill these later.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('articles', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('articles', 'cover_disk')) {
|
||||
$table->string('cover_disk')->nullable()->after('legacy_attachments');
|
||||
}
|
||||
if (! Schema::hasColumn('articles', 'cover_path')) {
|
||||
$table->string('cover_path')->nullable()->after('cover_disk');
|
||||
}
|
||||
if (! Schema::hasColumn('articles', 'cover_source')) {
|
||||
$table->string('cover_source', 32)->default('none')->after('cover_path');
|
||||
}
|
||||
if (! Schema::hasColumn('articles', 'cover_status')) {
|
||||
$table->string('cover_status', 32)->default('none')->after('cover_source');
|
||||
}
|
||||
if (! Schema::hasColumn('articles', 'cover_generated_at')) {
|
||||
$table->timestamp('cover_generated_at')->nullable()->after('cover_status');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('articles', function (Blueprint $table) {
|
||||
foreach (['cover_disk', 'cover_path', 'cover_source', 'cover_status', 'cover_generated_at'] as $column) {
|
||||
if (Schema::hasColumn('articles', $column)) {
|
||||
$table->dropColumn($column);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$this->call(DemoBlogSeeder::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Domain\Blog\ContentFormat;
|
||||
use App\Domain\Plugin\PluginManager;
|
||||
use App\Models\Article;
|
||||
use App\Models\Category;
|
||||
use App\Models\Comment;
|
||||
use App\Models\Link;
|
||||
use App\Models\Stylevar;
|
||||
use App\Models\Tag;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class DemoBlogSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
Role::findOrCreate('admin');
|
||||
Role::findOrCreate('editor');
|
||||
Role::findOrCreate('member');
|
||||
|
||||
$plugins = app(PluginManager::class);
|
||||
$plugins->syncDiscoveredPlugins();
|
||||
try {
|
||||
$plugins->enable('larablog/ai-comment-moderation');
|
||||
} catch (\Throwable) {
|
||||
//
|
||||
}
|
||||
|
||||
$admin = User::query()
|
||||
->where('email', 'admin@larablog.test')
|
||||
->orWhere('username', 'admin')
|
||||
->first();
|
||||
|
||||
if ($admin === null) {
|
||||
$admin = User::query()->create([
|
||||
'email' => 'admin@larablog.test',
|
||||
'name' => 'Admin',
|
||||
'username' => 'admin',
|
||||
'password' => 'password',
|
||||
]);
|
||||
} else {
|
||||
$admin->forceFill([
|
||||
'email' => 'admin@larablog.test',
|
||||
'name' => 'Admin',
|
||||
'username' => 'admin',
|
||||
'password' => 'password',
|
||||
])->save();
|
||||
}
|
||||
$admin->assignRole('admin');
|
||||
|
||||
$category = Category::query()->updateOrCreate(
|
||||
['id' => 1],
|
||||
['name' => '随笔', 'display_order' => 0, 'articles_count' => 2]
|
||||
);
|
||||
|
||||
$html = Article::query()->updateOrCreate(
|
||||
['id' => 1],
|
||||
[
|
||||
'category_id' => $category->id,
|
||||
'user_id' => $admin->id,
|
||||
'title' => '欢迎使用 LaraBlog(HTML 样例)',
|
||||
'content' => '<p>这是一篇 <strong>HTML</strong> 正文,来自旧站风格。</p><p>你可以在后台切换主题、启停插件,并用 Markdown 继续写作。</p>',
|
||||
'content_format' => ContentFormat::HTML,
|
||||
'description' => 'HTML 格式演示',
|
||||
'published_at' => now()->subDay(),
|
||||
'visible' => true,
|
||||
'stick' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$md = Article::query()->updateOrCreate(
|
||||
['id' => 2],
|
||||
[
|
||||
'category_id' => $category->id,
|
||||
'user_id' => $admin->id,
|
||||
'title' => 'Markdown 才是未来',
|
||||
'content' => "# Hello Markdown\n\n这是 **Markdown** 正文。\n\n- 主题可切换\n- 插件可启停\n- SEO / llms.txt 已就绪\n",
|
||||
'content_format' => ContentFormat::MARKDOWN,
|
||||
'description' => 'Markdown 格式演示',
|
||||
'published_at' => now(),
|
||||
'visible' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$tag = Tag::query()->updateOrCreate(['name' => 'larablog'], ['use_count' => 2]);
|
||||
$tag->articles()->syncWithoutDetaching([$html->id, $md->id]);
|
||||
|
||||
Comment::query()->updateOrCreate(
|
||||
['id' => 1],
|
||||
[
|
||||
'article_id' => $md->id,
|
||||
'author' => '访客',
|
||||
'content' => '看起来不错',
|
||||
'moderation_status' => Comment::STATUS_APPROVED,
|
||||
'published_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
Link::query()->updateOrCreate(
|
||||
['id' => 1],
|
||||
[
|
||||
'name' => 'Laravel',
|
||||
'url' => 'https://laravel.com',
|
||||
'note' => 'PHP 框架',
|
||||
'visible' => true,
|
||||
]
|
||||
);
|
||||
|
||||
Stylevar::query()->updateOrCreate(
|
||||
['id' => 1],
|
||||
[
|
||||
'title' => 'sidebar_note',
|
||||
'value' => 'LaraBlog · 现代博客引擎',
|
||||
'visible' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
|
||||
return new class extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->migrator->inGroup('general', function ($blueprint): void {
|
||||
$blueprint->add('site_name', config('app.name', 'LaraBlog'));
|
||||
$blueprint->add('site_url', config('app.url', 'http://localhost'));
|
||||
$blueprint->add('site_description', null);
|
||||
$blueprint->add('active_theme', 'default');
|
||||
$blueprint->add('attachments_url_prefix', env('ATTACHMENTS_URL_PREFIX', 'attachments'));
|
||||
});
|
||||
|
||||
$this->migrator->inGroup('seo', function ($blueprint): void {
|
||||
$blueprint->add('meta_title_suffix', null);
|
||||
$blueprint->add('default_description', null);
|
||||
$blueprint->add('default_keywords', null);
|
||||
$blueprint->add('json_ld_enabled', true);
|
||||
});
|
||||
|
||||
$this->migrator->inGroup('ai', function ($blueprint): void {
|
||||
$blueprint->add('provider', env('AI_PROVIDER', 'stub'));
|
||||
$blueprint->add('api_base_url', env('AI_API_BASE_URL'));
|
||||
$blueprint->add('api_key', env('AI_API_KEY'));
|
||||
$blueprint->add('model', env('AI_MODEL', 'gpt-4o-mini'));
|
||||
$blueprint->add('comment_moderation_enabled', true);
|
||||
$blueprint->add('content_optimization_enabled', true);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
|
||||
return new class extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! $this->migrator->exists('general.attachments_url_prefix')) {
|
||||
$this->migrator->inGroup('general', function ($blueprint): void {
|
||||
$blueprint->add('attachments_url_prefix', env('ATTACHMENTS_URL_PREFIX', 'attachments'));
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
|
||||
return new class extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if ($this->migrator->exists('general.trackback_enabled')) {
|
||||
$this->migrator->delete('general.trackback_enabled');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
|
||||
return new class extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->migrator->inGroup('general', function ($blueprint): void {
|
||||
// New posts in admin default to markdown.
|
||||
$blueprint->add('default_content_format', 'markdown');
|
||||
// Import keeps sablog HTML unless --convert-to-markdown is passed.
|
||||
$blueprint->add('import_content_format', 'html');
|
||||
// When true, sablog:import may convert HTML body to Markdown.
|
||||
$blueprint->add('import_convert_html_to_markdown', false);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
|
||||
return new class extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->migrator->inGroup('blog', function ($blueprint): void {
|
||||
$blueprint->add('posts_per_page', 10);
|
||||
$blueprint->add('allow_comments', true);
|
||||
$blueprint->add('comment_order', 'asc');
|
||||
$blueprint->add('show_views', true);
|
||||
$blueprint->add('show_author', true);
|
||||
$blueprint->add('date_format', 'Y-m-d');
|
||||
$blueprint->add('close_comments_on_old_posts', false);
|
||||
$blueprint->add('close_comments_days', 90);
|
||||
});
|
||||
|
||||
$this->migrator->inGroup('comment', function ($blueprint): void {
|
||||
$blueprint->add('guest_can_comment', true);
|
||||
$blueprint->add('require_moderation', false);
|
||||
$blueprint->add('rate_limit_per_minute', 5);
|
||||
$blueprint->add('enable_website_field', true);
|
||||
$blueprint->add('forbidden_words', '');
|
||||
});
|
||||
|
||||
$this->migrator->inGroup('seo', function ($blueprint): void {
|
||||
$blueprint->add('robots_index', true);
|
||||
$blueprint->add('twitter_site', null);
|
||||
$blueprint->add('canonical_force_https', false);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
|
||||
return new class extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->migrator->inGroup('snippets', function ($blueprint): void {
|
||||
$blueprint->add('analytics_head', '');
|
||||
$blueprint->add('body_end', '');
|
||||
$blueprint->add('ads_sidebar', '');
|
||||
$blueprint->add('ads_article_top', '');
|
||||
$blueprint->add('ads_article_bottom', '');
|
||||
$blueprint->add('header_banner', '');
|
||||
$blueprint->add('custom_links_html', '');
|
||||
$blueprint->add('footer_html', '');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user