This commit is contained in:
2024-03-17 16:30:27 +01:00
parent 93b7402a16
commit c5a1a42923
15 changed files with 435 additions and 35 deletions

View File

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