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;
|
||||
|
@@ -28,7 +28,11 @@
|
||||
@if($edit = auth()->check() && auth()->user()->can('edit_video'))
|
||||
<form action="/index/{{$video->id}}" method="post" id="edit_{{$video->id}}" class="indexform"></form>
|
||||
@endif
|
||||
<span class="vinfo vid"><a href="{{url($video->id)}}">{{$video->id}}</a></span>
|
||||
@if(isset($q))
|
||||
<span class="vinfo vid"><a href="/t/{{$q}}/{{$video->id}}">{{$video->id}}</a></span>
|
||||
@else
|
||||
<span class="vinfo vid"><a href="{{url($video->id)}}">{{$video->id}}</a></span>
|
||||
@endif
|
||||
@if($edit)
|
||||
<input type="submit" class="btn btn-primary" value="Save" form="edit_{{$video->id}}">
|
||||
@endif
|
||||
|
@@ -16,7 +16,11 @@
|
||||
$thumb = str_replace(".webm","",$video->file);
|
||||
?>
|
||||
<div class="main-item">
|
||||
<a href="/{{$video->id}}">
|
||||
@if(isset($q))
|
||||
<a href="/t/{{$q}}/{{$video->id}}">
|
||||
@else
|
||||
<a href="/{{$video->id}}">
|
||||
@endif
|
||||
{{-- MUSS UNBEDINGT NOCH ANGEPASST WERDEN!!! --}}
|
||||
@if(file_exists(public_path() . '/thumbs/beta/'.$thumb.'.png'))
|
||||
<img src="/thumbs/beta/{{$thumb}}.png">
|
||||
|
Reference in New Issue
Block a user