mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 05:00:49 +08:00
56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class Snatch extends NexusModel
|
|
{
|
|
protected $table = 'snatched';
|
|
|
|
protected $fillable = [
|
|
'torrentid', 'userid', 'ip', 'port', 'uploaded', 'downloaded', 'to_go', 'seedtime', 'leechtime',
|
|
'last_action', 'startdat', 'completedat', 'finished'
|
|
];
|
|
|
|
protected $casts = [
|
|
'last_action' => 'datetime',
|
|
'startdat' => 'datetime',
|
|
'completedat' => 'datetime',
|
|
];
|
|
|
|
public static $cardTitles = [
|
|
'upload_text' => '上传',
|
|
'download_text' => '下载',
|
|
'share_ratio' => '分享率',
|
|
'seed_time' => '做种时间',
|
|
'leech_time' => '下载时间',
|
|
'completed_at_human' => '完成',
|
|
];
|
|
|
|
const FINISHED_YES = 'yes';
|
|
|
|
const FINISHED_NO = 'no';
|
|
|
|
public function scopeIsFinished(Builder $builder)
|
|
{
|
|
return $builder->where('finished', self::FINISHED_YES);
|
|
}
|
|
|
|
public function scopeIsNotFinished(Builder $builder)
|
|
{
|
|
return $builder->where('finished', self::FINISHED_NO);
|
|
}
|
|
|
|
public function torrent()
|
|
{
|
|
return $this->belongsTo(Torrent::class, 'torrentid');
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'userid');
|
|
}
|
|
}
|