コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $video = Video::find(1);
     for ($i = 1; $i <= 3; $i++) {
         $data = ['user_id' => User::find($i)->id, 'video_id' => $video->id, 'comment' => 'Lorem ipsum comment'];
         Comment::create($data);
     }
 }
コード例 #2
0
 /**
  * Delete a video.
  *
  * @param $slug
  * @return mixed
  */
 public function delete($slug)
 {
     $slug = explode('-', $slug);
     $id = $slug[0];
     $video = $this->video->find($id);
     if ($video->count() > 0) {
         $video->delete();
         return redirect('dashboard/videos')->withSuccess('Video removed');
     }
     abort(404);
 }
コード例 #3
0
 /**
  * Watch a video fully.
  *
  * @param $slug
  * @return mixed
  */
 public function watchVideo($slug)
 {
     $slug = explode('-', $slug);
     $id = $slug[0];
     $video = $this->video->find($id);
     if ($video->count() > 0) {
         $this->userVideo->create(['user_id' => \Auth::user()->id, 'video_id' => $id]);
         return redirect()->back()->withSuccess('Video watched');
     }
     abort(404);
 }
コード例 #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $video = Video::find(1);
     $type = ['like', 'dislike'];
     for ($i = 0; $i < 100; $i++) {
         $user = $this->createUser();
         $key = array_rand($type);
         $data = ['user_id' => $user->id, 'video_id' => $video->id, 'type' => $type[$key]];
         LikeDislike::create($data);
     }
 }
コード例 #5
0
ファイル: VideosController.php プロジェクト: jgt/ceprog
 public function delete($id, Request $request)
 {
     $video = Video::find($id);
     $public_path = public_path();
     $file = $public_path . '/uploads/' . $video->original_filename;
     if ($file) {
         Archivo::delete($file);
         $video->delete();
     }
     if ($request->ajax()) {
         return response()->json($video);
     }
 }
コード例 #6
0
 /**
  * @return Video|best
  */
 public function best()
 {
     $videos = Video::all();
     $best_vidos = [];
     $id_best_videos = [];
     foreach ($videos as $video) {
         $id_best_videos[] = [$video->likes()->count(), $video->id];
     }
     arsort($id_best_videos);
     $id_best_videos = array_slice($id_best_videos, 0, 10);
     foreach ($id_best_videos as $value) {
         $best_vidos[] = Video::find($value[1]);
     }
     return $best_vidos;
 }
コード例 #7
0
ファイル: VideoController.php プロジェクト: goyuquan/album
 public function update(Request $request, $id)
 {
     $video = Video::findOrFail($id);
     if (Gate::denies('video_authorize', $video)) {
         return "authorize fails";
     }
     $messages = ['title.required' => '标题不能为空', 'title.max' => '标题不能小于:max位', 'title.min' => '标题不能小于:min位'];
     $this->validate($request, ['title' => 'required|min:3|max:255'], $messages);
     $video = Video::find($id);
     $video->title = $request->title;
     $video->content = $request->content;
     $video->display_id = $request->display;
     $video->thumbnail = $request->thumbnail;
     $video->thumbnail2 = $request->thumbnail;
     $video->video = $request->video;
     $video->free = $request->free;
     $video->published_at = $request->published_at;
     $video->save();
     Session()->flash('status', 'video update was successful!');
     return redirect('/admin/videos/');
 }
コード例 #8
0
 /**
  * Set a Album cover.
  *
  * @param $id
  * @return Response
  */
 public function getAlbumCover($id, $album = 0)
 {
     $video = Video::find($id);
     $videoalbums = Video::where('video_album_id', $video->video_album_id)->get();
     foreach ($videoalbums as $item) {
         $item->album_cover = 0;
         $item->save();
     }
     $video->album_cover = 1;
     $video->save();
     // Show the page
     return redirect($album == 0 ? '/admin/video' : '/admin/video/' . $album . '/itemsforalbum');
 }
コード例 #9
0
ファイル: VdController.php プロジェクト: ronal2do/stq001
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $post = Video::find($id);
     $post->delete();
     return redirect("editarvideo");
 }
コード例 #10
0
 /**
  * Delete a user's uploaded video resource from the database
  */
 public function deleteVideo(Request $request)
 {
     $video = Video::find($request->input('id'));
     $videoTitle = $video->title;
     $video->delete();
     $videos = ViewsController::getLoggedInUserVideos();
     return view('dashboard', ['videos' => $videos, 'message' => 'The video "' . $videoTitle . '" was deleted.']);
 }
コード例 #11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $video = Video::find($id);
     $video->delete();
     // redirect
     \Session::flash('message', 'Successfully deleted!!');
     return \Redirect::to('admin/videos');
 }
コード例 #12
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(StoreProductRequest $request, $id)
 {
     $product = Product::find($id)->fill($request->all());
     $product->type = Product::find($id)->type;
     // validate request further according to type
     switch ($request->type) {
         case 'MOVIE':
         case 'SERIES':
         case 'ANIME':
         case 'VIDEO':
             $valRequest = new UpdateVideoRequest();
             $this->validate($request, $valRequest->rules());
             $info = Video::find($product->id)->fill($request->video);
             break;
         case 'GAME':
             $valRequest = new UpdateGameRequest();
             $this->validate($request, $valRequest->rules());
             $info = Game::find($product->id)->fill($request->video);
             break;
     }
     if (in_array($request->type, ['MOVIE', 'SERIES', 'ANIME', 'VIDEO'])) {
         $this->UpdateVideo($request, $product, $info);
     } else {
         if ($request->type == "GAME") {
             $this->UpdateGame($request, $product, $info);
         }
     }
     // flash message
     session()->flash('flash_message', 'Product updated successfully.');
     return redirect()->route('home');
 }
コード例 #13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $video = Video::find($id);
     $video->delete();
     return response()->json(['success' => true, 'message' => 'Video "' . $video->titulo . '" eliminado correctamente', 'id' => $video->id]);
 }
コード例 #14
0
 public function editvideo(Request $request)
 {
     $data = $request->all();
     $validator = Validator::make($request->all(), ['title' => 'required|max:255', 'embed' => 'required']);
     if ($validator->fails()) {
         return redirect('/admin/videos/add')->withErrors($validator)->withInput();
     }
     $id = $data['id'];
     $videos = Video::find($id);
     $videos->title = $data['title'];
     $videos->embed = $data['embed'];
     $videos->save();
     return redirect('/admin/videos');
 }
コード例 #15
0
 public function destroy($id)
 {
     $video = Video::find($id);
     $video->delete();
     return $this->setStatusCode(200)->respond(["message" => "succesfully deleted the video"]);
 }
コード例 #16
0
ファイル: VideoController.php プロジェクト: Techraav/djMaker
 public function getVideo($id)
 {
     $video = Video::find($id);
     return response()->json($video);
 }
コード例 #17
0
 /**
  * Удаление видео.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function getDelete(Request $request)
 {
     $id = $request->segment(6);
     $video = Video::find($id);
     if (empty($video)) {
         abort(404);
     }
     $video->delete();
     return redirect()->action('Admin\\VideosController@getIndex', ['company' => $request->segment(3)])->with('success', 'Видео успешно удалено.');
 }
コード例 #18
0
ファイル: VideosController.php プロジェクト: spspasov/video
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $video = Video::find($id);
     return view('videos.show', ['video' => $video]);
 }