mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
class Torrent extends NexusModel
|
|
{
|
|
protected $fillable = [
|
|
'name', 'filename', 'save_as', 'descr', 'small_descr', 'ori_descr',
|
|
'category', 'source', 'medium', 'codec', 'standard', 'processing', 'team', 'audiocodec',
|
|
'size', 'added', 'type', 'numfiles', 'owner', 'nfo', 'sp_state', 'promotion_time_type',
|
|
'promotion_until', 'anonymous', 'url', 'pos_state', 'cache_stamp', 'picktype', 'picktime',
|
|
'last_reseed', 'pt_gen', 'tags', 'technical_info'
|
|
];
|
|
|
|
const VISIBLE_YES = 'yes';
|
|
const VISIBLE_NO = 'no';
|
|
|
|
const BANNED_YES = 'yes';
|
|
const BANNED_NO = 'no';
|
|
|
|
public $timestamps = true;
|
|
|
|
public function checkIsNormal(array $fields = ['visible', 'banned'])
|
|
{
|
|
if (in_array('visible', $fields) && $this->getAttribute('visible') != self::VISIBLE_YES) {
|
|
throw new \InvalidArgumentException(sprintf('Torrent: %s is not visible.', $this->id));
|
|
}
|
|
if (in_array('banned', $fields) && $this->getAttribute('banned') == self::BANNED_YES) {
|
|
throw new \InvalidArgumentException(sprintf('Torrent: %s is banned.', $this->id));
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|