You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace Database\Seeders;
use App\Models\Paper;
use App\Models\Teacher;
use App\Models\University;
use Illuminate\Database\Seeder;
/**
* 演示论文库数据(对齐 prototype papers.html
*/
class PaperSampleSeeder extends Seeder
{
public function run(): void
{
$sjtu = University::query()->where('name', '上海交通大学')->first();
$zju = University::query()->where('name', '浙江大学')->first();
$fdu = University::query()->where('name', '复旦大学')->first();
$samples = [
[
'title' => 'Graph Neural Networks for Materials Discovery',
'authors' => 'Zhang, Li',
'school_name' => '上海交通大学',
'university_id' => $sjtu?->id,
'published_at' => '2025-11-01',
'url' => 'https://example.com/paper/gnn-materials',
'summary' => '图神经网络在材料发现中的高通量筛选方法。',
'source' => 'crawl',
],
[
'title' => 'Efficient LLM Inference on Edge Devices',
'authors' => 'Wang et al.',
'school_name' => '浙江大学',
'university_id' => $zju?->id,
'published_at' => '2026-01-01',
'url' => 'https://example.com/paper/llm-edge',
'summary' => '面向边缘端的低延迟大模型推理优化。',
'source' => 'crawl',
],
[
'title' => 'Multiscale simulation workflow for catalyst screening',
'authors' => 'Sun Wei',
'school_name' => '复旦大学',
'university_id' => $fdu?->id,
'published_at' => '2024-09-01',
'url' => 'https://example.com/paper/catalyst-screening',
'summary' => '结合多尺度模拟与机器学习排序的催化剂候选材料筛选流程。',
'source' => 'manual',
],
];
foreach ($samples as $row) {
$paper = Paper::query()->firstOrCreate(
['title' => $row['title']],
$row
);
if ($row['source'] === 'manual' && $sjtu) {
$teacher = Teacher::query()
->where('university_id', $sjtu->id)
->where('name', '张某某')
->first();
if ($teacher) {
$teacher->papers()->syncWithoutDetaching([$paper->id]);
}
}
}
}
}