This commit is contained in:
2024-03-18 17:56:29 +01:00
parent c5a1a42923
commit a525c12794
2 changed files with 32 additions and 18 deletions

View File

@@ -39,25 +39,32 @@ class TagviewController extends Controller
public function tagview($tag, $id = null) public function tagview($tag, $id = null)
{ {
if (is_null($tag)) { if (is_null($id)) {
return "penis"; // $x = Video::with('tags')->get();
} // return $x;
// return $tag; $x = Video::orderByRaw("RAND()")->with('tags')->whereHas('tags', function ($query) use ($tag) {
// $tag = $query->where('normalized', $tag);
$video = Video::getRandom($tag); })->first();
return $video; // $x = Video::orderByRaw("RAND()")->with('tags')->get()->first();
$responseArray = json_decode($x, true);
$normalizedTags = array_column($responseArray['tags'], 'normalized');
//$video = Video::with('tags')->find($tag->id); $variableToCompare = $tag;
if(!$id) { if (in_array($variableToCompare, $normalizedTags)) {
// id unset // tag exists
return redirect('t/' . $tag . '/' . $video->id); return redirect('t/' . $tag . '/' . $x->id);
} else { } else {
// tag does not exist on video
return view('tagviewdev',[ return 404;
}
} else {
// return $id;
$video = Video::where('id', $id)->with('tags')->get();
return view('tagviewdev', [
'video' => $video, 'video' => $video,
'related' => $video 'related' => $video,
'tag' => $tag
]); ]);
} }
} }

View File

@@ -1 +1,8 @@
{{$related}} lol
<a href="/t/{{$tag}}">rand</a>
<br>
leon du huan
<br>
<video controls src="/b/{{ $video[0]['file'] }}"></video>
<br>