fixing tagview #2
This commit is contained in:
@@ -40,9 +40,9 @@ class TagviewController extends Controller
|
||||
public function showVideo($shortname, $id = null)
|
||||
{
|
||||
// return $shortname;
|
||||
|
||||
$tags = app(TagService::class)->buildTagArray($shortname);
|
||||
if (is_null($id)) {
|
||||
$video = Video::getRandom($shortname, true);
|
||||
$video = Video::getRandom($tags, true);
|
||||
|
||||
if (!($video instanceof RedirectResponse)) {
|
||||
$video = $video->first();
|
||||
@@ -54,7 +54,7 @@ class TagviewController extends Controller
|
||||
} else {
|
||||
// Don't filter on specific video.
|
||||
// TODO: Add warning page
|
||||
$video = Video::withAnyTags($shortname)->find($id);
|
||||
$video = Video::withAllTags($tags)->find($id);
|
||||
}
|
||||
|
||||
if (is_null($video)) {
|
||||
|
@@ -187,7 +187,7 @@ Route::group(["middleware" => "theme"], function() {
|
||||
Route::get('{shortname}/{id}', 'CategoryController@showVideo')->where(['shortname' => '[a-z][a-z0-9]+', 'id' => '[0-9]+']);
|
||||
|
||||
##Tag View anybody?
|
||||
Route::get('t/{tag}', 'TagviewController@showVideo')->where('tag', '[a-z][a-z0-9]+');
|
||||
Route::get('t/{tag}/{id}', 'TagviewController@showVideo')->where(['tag' => '[a-z][a-z0-9]+', 'id' => '[0-9]+']);
|
||||
Route::get('t/{tag}', 'TagviewController@showVideo')->where('tag', '[a-z][a-z0-9,]+');
|
||||
Route::get('t/{tag}/{id}', 'TagviewController@showVideo')->where(['tag' => '[a-z][a-z0-9,]+', 'id' => '[0-9]+']);
|
||||
|
||||
});
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user