mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
torrent api + swip constants
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user