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.
49 lines
1.0 KiB
49 lines
1.0 KiB
|
2 weeks ago
|
<?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();
|
||
|
|
}
|
||
|
|
}
|