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

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