fixing tagview #2

This commit is contained in:
x
2024-06-10 01:10:33 +02:00
parent 05f7fa5732
commit b6d93f54ef
5 changed files with 27 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Cviebrock\EloquentTaggable\Services\TagService;
/**
* App\Models\Video
@@ -72,7 +73,8 @@ class Video extends Model
if (!$isTag) {
return $related->videos()->filtered()->orderBy('id', 'ASC')->first()->id;
}
return Video::withAnyTags($related)->filtered()->orderBy('id', 'ASC')->first()->id;
$related = app(TagService::class)->buildTagArray($related);
return Video::withAllTags($related)->filtered()->orderBy('id', 'ASC')->first()->id;
}
return static::filtered()->orderBy('id', 'ASC')->first()->id;
}
@@ -82,7 +84,8 @@ class Video extends Model
if (!$isTag) {
return $related->videos()->filtered()->orderBy('id', 'DESC')->first()->id;
}
return Video::withAnyTags($related)->filtered()->orderBy('id', 'DESC')->first()->id;
$related = app(TagService::class)->buildTagArray($related);
return Video::withAllTags($related)->filtered()->orderBy('id', 'DESC')->first()->id;
}
return static::select('id')->filtered()->orderBy('id', 'DESC')->first()->id;
}
@@ -92,7 +95,8 @@ class Video extends Model
if (!$isTag) {
return $related->videos()->filtered()->where('id', '>', $this->id)->orderBy('id', 'ASC')->first();
}
return Video::withAnyTags($related)->filtered()->where('id', '>', $this->id)->orderBy('id', 'ASC')->first();
$related = app(TagService::class)->buildTagArray($related);
return Video::withAllTags($related)->filtered()->where('id', '>', $this->id)->orderBy('id', 'ASC')->first();
} else {
return static::filtered()->where('id', '>', $this->id)->orderBy('id', 'ASC')->first();
}
@@ -103,7 +107,8 @@ class Video extends Model
if (!$isTag) {
return $related->videos()->filtered()->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
}
return Video::withAnyTags($related)->filtered()->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
$related = app(TagService::class)->buildTagArray($related);
return Video::withAllTags($related)->filtered()->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
} else {
return static::filtered()->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
}
@@ -243,13 +248,14 @@ public function blurryThumb() {
return $related->videos()->filtered()->skip($id);
}
// jetzt sind wir im tag
$id = Video::withAnyTags($related)->filtered()->countScoped()->count()-1;
$related = app(TagService::class)->buildTagArray($related);
$id = Video::withAllTags($related)->filtered()->countScoped()->count()-1;
if ($id < 0) {
return redirect()->back()->with('error', 'no videos found');
}
$id = mt_rand(0,$id);
return Video::withAnyTags($related)->filtered()->skip($id);
return Video::withAllTags($related)->filtered()->skip($id);
}
$id = static::filtered()->countScoped()->count() - 1;