...
This commit is contained in:
@@ -42,7 +42,6 @@ class CategoryController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
@@ -52,10 +51,12 @@ class CategoryController extends Controller
|
||||
*/
|
||||
public function showVideo($shortname, $id = null)
|
||||
{
|
||||
// return $shortname;
|
||||
$category = Category::whereShortname($shortname)->first();
|
||||
if (is_null($category)) {
|
||||
return redirect()->back()->with('error', 'Category not found');
|
||||
}
|
||||
|
||||
if (is_null($id)) {
|
||||
$video = Video::getRandom($category);
|
||||
if ($video instanceof HasMany) {
|
||||
@@ -70,6 +71,7 @@ class CategoryController extends Controller
|
||||
// TODO: Add warning page
|
||||
$video = $category->videos()->find($id);
|
||||
}
|
||||
|
||||
if (is_null($video)) {
|
||||
return redirect()->back()->with('error', 'Category is empty.');
|
||||
}
|
||||
|
118
app/Http/Controllers/DebugController.php
Normal file
118
app/Http/Controllers/DebugController.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Tag;
|
||||
|
||||
class DebugController extends Controller
|
||||
{
|
||||
public function getRandomVideoForCategory(Category $category)
|
||||
{
|
||||
$randomVideo = \App\Models\Video::getRandom($category);
|
||||
|
||||
// Now you can return or use $randomVideo as needed
|
||||
}
|
||||
|
||||
public function getRandomVideoForTag(Tag $tag)
|
||||
{
|
||||
$randomVideo = \App\Models\Video::getRandom($tag);
|
||||
|
||||
// Now you can return or use $randomVideo as needed
|
||||
}
|
||||
|
||||
public function getSingleRandomVideoForCategory(Category $category)
|
||||
{
|
||||
$singleRandomVideo = \App\Models\Video::getSingleRandom($category);
|
||||
|
||||
// Now you can return or use $singleRandomVideo as needed
|
||||
}
|
||||
|
||||
public function getSingleRandomVideoForTag(Tag $tag)
|
||||
{
|
||||
$singleRandomVideo = \App\Models\Video::getSingleRandom($tag);
|
||||
|
||||
// Now you can return or use $singleRandomVideo as needed
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
230
app/Http/Controllers/TagviewController.php
Normal file
230
app/Http/Controllers/TagviewController.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Video;
|
||||
use App\Models\Banner;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
use App\Http\Requests;
|
||||
class TagviewController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index($tag)
|
||||
{
|
||||
$tag = $video = Video::with('tags')->find($tag->id);
|
||||
return $tag;
|
||||
// $tag = Video::withAnyTags($tag)->first();
|
||||
// return $tag;
|
||||
// $video = Video::with('tags')->find($tag->id);
|
||||
// return redirect('t/' . $tag->normalized . '/' . $video->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
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',[
|
||||
'video' => $video,
|
||||
'related' => $video
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// public function tagview($tag, $id = null)
|
||||
// {
|
||||
// $x = Video::withAllTags($tag)->first();
|
||||
|
||||
// // return $x;
|
||||
// // id 1
|
||||
// // file "1.webm"
|
||||
// // videotitle "su"
|
||||
// // interpret null
|
||||
// // songtitle null
|
||||
// // imgsource null
|
||||
// // category_id 8
|
||||
// // user_id 1
|
||||
// // created_at "2024-02-22 00:31:49"
|
||||
// // updated_at "2024-02-22 00:31:49"
|
||||
// // deleted_at null
|
||||
// // hash "3cdd7e0aa1a1cf175e06f22da2f485091f3b9f22"
|
||||
// // tag_id 2
|
||||
// // taggable_id 1
|
||||
// // taggable_type "App\\Models\\Video"
|
||||
// // name "misc"
|
||||
// // normalized "misc"
|
||||
|
||||
// if(!$id) {
|
||||
// // gibs keine...
|
||||
// $z = Video::getAllTags();
|
||||
// return $z;
|
||||
// } else {
|
||||
// $y = $x->id;
|
||||
// return $y;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public function tagview($tag, $id = null)
|
||||
// {
|
||||
// // $tag_in = Video::withAnyTags($tag)->first();
|
||||
// // return $tag_in;
|
||||
// $video = Video::getRandom($tag->id);
|
||||
// if ($video instanceof HasMany) {
|
||||
// $video = $video->first();
|
||||
// }
|
||||
// // $video = Video::getRandom($tag->id);
|
||||
|
||||
// if (is_null($id)) {
|
||||
// $video = Video::getRandom($tag);
|
||||
// } else {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// public function helloworld($tag, $id = null)
|
||||
// {
|
||||
// if(!$tag) {
|
||||
// return redirect()->back()->with('error', 'Tag not found');
|
||||
// }
|
||||
|
||||
// if (is_null($id)) {
|
||||
// $tag = Video::withAnyTags($tag)->first();
|
||||
// return redirect('t/' . $tag->normalized . '/' . $tag->id);
|
||||
// } else {
|
||||
// $tag = Video::withAnyTags($tag)->first();
|
||||
// $video = Video::with('tags')->find($tag->id);
|
||||
|
||||
// return view('tagviewdev', [
|
||||
// 'id' => $tag->id,
|
||||
// 'video' => $video,
|
||||
// 'tag' => $tag->name,
|
||||
// 'related' => $video->name,
|
||||
// 'banner' => 'banner'
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// if(!$id) {
|
||||
// // is not null
|
||||
// // implement redirect to t/$tag/$id
|
||||
// } else {
|
||||
// $tag = Video::withAnyTags($tag)->first();
|
||||
// // reverse lookup of $video thanks to the api for tag
|
||||
// $video = Video::with('tags')->find($tag->id);
|
||||
|
||||
// $tags = $video->tags;
|
||||
|
||||
// return view('tagviewdev', [
|
||||
// 'video' => $video,
|
||||
// 'tags' => $tags,
|
||||
// 'related' => $tag->name
|
||||
// ]);
|
||||
// //return redirect('t/' . $tag . '/' . );
|
||||
// }
|
||||
|
||||
// $blub = $tag->id;
|
||||
// return $blub;
|
||||
|
||||
// if (is_null($id)) {
|
||||
|
||||
// $video = Video::getRandom($tag);
|
||||
// if ($video instanceof HasMany) {
|
||||
// $video = $video->first();
|
||||
// }
|
||||
// else {
|
||||
// return redirect()->back()->with('error', '404');
|
||||
// }
|
||||
// return redirect('t/' . $tag . '/' . $video->id);
|
||||
// } else {
|
||||
// // Don't filter on specific video.
|
||||
// // TODO: Add warning page
|
||||
// // $video = $tag->videos()->find($id);
|
||||
// }
|
||||
|
||||
// //return $tag;
|
||||
// return view('tagviewdev', [
|
||||
// 'tag' => $tag,
|
||||
// 'related' => $tag,
|
||||
// ]);
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user