mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
74 lines
1.5 KiB
PHP
74 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class Peer extends NexusModel
|
|
{
|
|
const CONNECTABLE_YES = 'yes';
|
|
|
|
const CONNECTABLE_NO = 'no';
|
|
|
|
protected $casts = [
|
|
'started' => 'datetime',
|
|
'last_action' => 'datetime',
|
|
'prev_action' => 'datetime',
|
|
];
|
|
|
|
public static $connectableText = [
|
|
self::CONNECTABLE_YES => '是',
|
|
self::CONNECTABLE_NO => '否',
|
|
];
|
|
|
|
const SEEDER_YES = 'yes';
|
|
|
|
const SEEDER_NO = 'no';
|
|
|
|
public static $cardTitles = [
|
|
'upload_text' => '上传',
|
|
'download_text' => '下载',
|
|
'share_ratio' => '分享率',
|
|
'agent_human' => '客户端',
|
|
'connect_time_total' => '连接时间',
|
|
'download_progress' => '完成进度',
|
|
|
|
];
|
|
|
|
public function getConnectableTextAttribute()
|
|
{
|
|
return self::$connectableText[$this->connectable] ?? '';
|
|
}
|
|
|
|
public function scopeIsSeeder(Builder $builder)
|
|
{
|
|
return $builder->where('seeder', self::SEEDER_YES);
|
|
}
|
|
|
|
public function scopeIsNotSeeder(Builder $builder)
|
|
{
|
|
return $builder->where('seeder', self::SEEDER_NO);
|
|
}
|
|
|
|
public function isSeeder()
|
|
{
|
|
return $this->seeder == self::SEEDER_YES;
|
|
}
|
|
|
|
public function isNotSeeder()
|
|
{
|
|
return $this->seeder == self::SEEDER_NO;
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'userid');
|
|
}
|
|
|
|
public function relative_torrent()
|
|
{
|
|
return $this->belongsTo(Torrent::class, 'torrent');
|
|
}
|
|
}
|