Exemple #1
0
 /**
  * @param bool $category
  * @return Video
  */
 public function getPrev($category = false)
 {
     if (!$category) {
         return Video::where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
     } else {
         return Video::whereCategoryId($this->category->id)->where('id', '<', $this->id)->orderBy('id', 'DESC')->first();
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  string  $shortname
  * @param int $id
  * @return \Response
  */
 public function showVideo($shortname, $id = null)
 {
     $category = Category::whereShortname($shortname)->first();
     if (is_null($category)) {
         return redirect()->back()->with('error', 'Category not found');
     }
     if (is_null($id)) {
         $id = Video::whereCategoryId($category->id)->count() - 1;
         if ($id < 0) {
             return redirect()->back()->with('error', 'Category is empty.');
         }
         $id = rand(0, $id);
         $video = Video::whereCategoryId($category->id)->skip($id)->first();
         return redirect($shortname . '/' . $video->id);
     } else {
         $video = Video::whereCategoryId($category->id)->find($id);
     }
     if (is_null($video)) {
         return redirect()->back()->with('error', 'Category is empty.');
     }
     return view('video', ['video' => $video, 'category' => true]);
 }
Exemple #3
0
 /**
  * Display the specified resource.
  *
  * @param  string  $shortname
  * @param int $id
  * @return \Response
  */
 public function showVideo($shortname, $id = null)
 {
     // GZ's kläglicher versuch:
     //if(!auth()->check()) return redirect('/irc')->with('error', 'You need to be logged in to view our content');
     $category = Category::whereShortname($shortname)->first();
     if (is_null($category)) {
         return redirect()->back()->with('error', 'Category not found');
     }
     if (is_null($id)) {
         $id = Video::whereCategoryId($category->id)->count() - 1;
         if ($id < 0) {
             return redirect()->back()->with('error', 'Category is empty.');
         }
         $id = rand(0, $id);
         $video = Video::whereCategoryId($category->id)->skip($id)->first();
         return redirect($shortname . '/' . $video->id);
     } else {
         $video = Video::whereCategoryId($category->id)->find($id);
     }
     if (is_null($video)) {
         return redirect()->back()->with('error', 'Category is empty.');
     }
     return view('video', ['video' => $video, 'category' => true]);
 }