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
+30 -10
View File
@@ -2,24 +2,44 @@
namespace Database\Seeders;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Models\Role;
class DatabaseSeeder extends Seeder
{
use WithoutModelEvents;
/**
* Seed the application's database.
*/
public function run(): void
{
// User::factory(10)->create();
foreach (['admin', 'editor', 'member'] as $role) {
Role::findOrCreate($role);
}
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
$admin = User::query()->firstOrCreate(
['email' => 'admin@laralog.test'],
[
'name' => '管理员',
'password' => Hash::make('password'),
]
);
$admin->assignRole('admin');
Setting::seedDefaults([
'site_name' => config('blog.name'),
'site_description' => config('blog.description'),
'site_icp' => config('blog.icp'),
'active_theme' => 'sablog',
'comment_audit' => '0',
'comment_min_len' => (string) config('blog.comment_min_len'),
'comment_max_len' => (string) config('blog.comment_max_len'),
'comment_post_space' => (string) config('blog.comment_post_space'),
'comment_order' => '1',
'rss_num' => (string) config('blog.rss_num'),
'seo_default_keywords' => '',
'seo_default_description' => '',
'site_closed' => '0',
'site_closed_note' => '系统升级中...',
]);
}
}