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.
55 lines
1.2 KiB
55 lines
1.2 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Paper extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'title',
|
|
'authors',
|
|
'university_id',
|
|
'school_name',
|
|
'published_at',
|
|
'url',
|
|
'summary',
|
|
'source',
|
|
'crawl_job_id',
|
|
'external_id',
|
|
'source_site',
|
|
];
|
|
|
|
protected $casts = [
|
|
'university_id' => 'integer',
|
|
'crawl_job_id' => 'integer',
|
|
'published_at' => 'date',
|
|
];
|
|
|
|
public function university(): BelongsTo
|
|
{
|
|
return $this->belongsTo(University::class);
|
|
}
|
|
|
|
public function crawlJob(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CrawlJob::class);
|
|
}
|
|
|
|
public function teachers(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Teacher::class, 'teacher_papers')->withTimestamps();
|
|
}
|
|
|
|
/** 待关联老师(与论文库 link_status=unlinked 口径一致) */
|
|
public function scopePendingTeacherLink($query)
|
|
{
|
|
return $query->doesntHave('teachers');
|
|
}
|
|
}
|