M1: 数据模型 + sablog:import 脚本(MySQL 8 验证通过,不迁移 trackback 等过时功能)

This commit is contained in:
ak
2026-08-11 17:40:13 +08:00
parent 8d526a8cfd
commit f16bb75538
17 changed files with 1010 additions and 13 deletions
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Support;
class MediaDisk
{
/**
* 实际生效的附件磁盘:
* 默认走 S3uploads);未配置 S3 密钥时回退本地 public,保证开发环境可用。
*/
public static function name(): string
{
$configured = config('blog.attachments_disk', 'uploads');
if ($configured === 'uploads' && empty(config('media.bucket'))) {
return 'public';
}
return $configured;
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Support;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class SlugGenerator
{
/**
* 生成唯一 slug。中文标题自动回退为 $fallback crc32 形式。
*/
public static function make(string $string, string $table, string $column = 'slug', ?int $ignoreId = null, ?string $fallback = null): string
{
$slug = Str::slug($string, '-', 'en');
if ($slug === '' || $slug === null) {
$slug = $fallback ?? $table.'-'.crc32($string);
}
$base = $slug;
$i = 2;
while (DB::table($table)->where($column, $slug)->where('id', '!=', $ignoreId ?? 0)->exists()) {
$slug = $base.'-'.$i++;
}
return $slug;
}
}