mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
show-exam
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user