Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(LikeRequest $request)
 {
     $input = $request->all();
     if (Auth::guest()) {
         \Session::flash('flash_message', 'You need to be logged in to like/dislike!');
     } else {
         $input['user_id'] = Auth::id();
         Like::create($input);
     }
     $video = Video::findOrFail($input['video_id']);
     return view('videos/show', compact('video'));
 }
Exemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CommentRequest $request)
 {
     $input = $request->all();
     if (Auth::guest()) {
         \Session::flash('flash_message', 'You need to be logged in to comment!');
     } else {
         $input['user_id'] = Auth::id();
         Comment::create($input);
     }
     $video = Video::findOrFail($input['video_id']);
     $test = Video::where('id', $input['video_id'])->increment('numComments');
     return view('videos/show', compact('video', 'test'));
 }
Exemplo n.º 3
0
 public function destroy($id)
 {
     $video = Video::findOrFail($id);
     if (Gate::denies('video_authorize', $video)) {
         return "authorize fails";
     }
     File::delete('videos/' . $video->video);
     File::delete('uploads/thumbnails/' . $video->thumbnail);
     File::delete('uploads/' . $video->thumbnail);
     File::delete('uploads/thumbnails/' . $video->thumbnail2);
     File::delete('uploads/' . $video->thumbnail2);
     Video::destroy($id);
     return redirect('/admin/videos/');
 }
Exemplo n.º 4
0
 public function show($id)
 {
     $video = Video::findOrFail($id);
     $video->increment('views');
     $video->views += 1;
     if (!Auth::guest()) {
         //$user = User::find(Auth::user()->id);
         $watch = false;
         foreach (Auth::user()->videos_watched as $userVideo) {
             if ($userVideo->id == $id) {
                 $watch = true;
             }
         }
         if (!$watch) {
             Auth::user()->videos_watched()->attach($id);
         }
     }
     return view('videos/show', compact('video'));
 }
Exemplo n.º 5
0
 public function getData($table, $id)
 {
     $result = '';
     try {
         switch ($table) {
             case 'feeds':
                 $result = Feed::findOrFail($id);
                 break;
             case 'meals':
                 $result = Meal::findOrFail($id);
                 break;
             case 'videos':
                 $result = Video::findOrFail($id);
                 break;
         }
         return $result;
     } catch (ModelNotFoundException $ex) {
         return false;
     }
 }
Exemplo n.º 6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $this->call('VideoTableSeeder');
     $this->command->info('Video table seeded!');
     $this->call('TagTableSeeder');
     $this->command->info('Tag table seeded!');
     $this->call('UserTableSeeder');
     $this->command->info('User table seeded!');
     $this->call('CommentTableSeeder');
     $this->command->info('Comment table seeded!');
     $this->call('TrackerTableSeeder');
     $this->command->info('Tracker table seeded!');
     $video = Video::findOrFail(1);
     $video->tags()->attach(1);
     //$video->comments()->attach(1);
     $video = Video::findOrFail(2);
     $video->tags()->attach(2);
     $video->tags()->attach(3);
     $user = User::findOrFail(2);
     $user->videos_watched()->attach(1);
     $user->videos_watched()->attach(2);
     $user->videos_liked()->attach(1);
     $user->videos_disliked()->attach(2);
 }
 public function findOrFail($id)
 {
     return Video::findOrFail($id);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return view('videos.show')->with('video', Video::findOrFail($id));
 }
Exemplo n.º 9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  VideoRequest $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(VideoRequest $request, $id)
 {
     try {
         $video = Video::findOrFail($id);
         $inputs = $request->all();
         $thumbnail = getVideoThumbnail($inputs['link']);
         $inputs['thumbnail'] = $thumbnail;
         $video->fill($inputs)->save();
     } catch (ModelNotFoundException $ex) {
         Flash::error('No video found' . $ex);
         return redirect()->route('videos.index');
     }
     Flash::success('Video updated successfully');
     return back();
 }