...
This commit is contained in:
@@ -51,6 +51,10 @@ class Video extends Model
|
||||
use SoftDeletes;
|
||||
use \Cviebrock\EloquentTaggable\Taggable;
|
||||
|
||||
public static function getTags() {
|
||||
return $tag_list;
|
||||
}
|
||||
|
||||
public function user() {
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
@@ -237,13 +241,24 @@ public function blurryThumb() {
|
||||
return static::filtered()->skip($id);
|
||||
}
|
||||
|
||||
public static function getSingleRandom($related = null) {
|
||||
$query = $related ? $related->videos()->filtered() : static::filtered();
|
||||
$count = $query->countScoped()->count();
|
||||
if ($count < 1) {
|
||||
return null; // Return null if no videos found
|
||||
}
|
||||
return $query->inRandomOrder()->first();
|
||||
}
|
||||
|
||||
public function isSfw() {
|
||||
return !$this->tags->contains(function ($key, $tag) {
|
||||
return $tag->normalized === 'nsfw';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function filesize() {
|
||||
return filesize(getcwd() . "/b/" . $this->file);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user