Files
nexusphp/app/Models/Torrent.php
xiaomlove 7cfde3f95b show-exam
2021-04-25 21:28:58 +08:00

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;
}
}