This commit is contained in:
2024-03-17 16:30:27 +01:00
parent 93b7402a16
commit c5a1a42923
15 changed files with 435 additions and 35 deletions

View File

@@ -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.');
}