public function index()
 {
     $AllSongInfo = Song_data::orderBy('id', 'desc')->take(5)->get();
     $AllVideosInfo = Videos::orderBy('id', 'desc')->take(5)->get();
     $LastVideo = Videos::orderBy('id', 'desc')->first();
     return view('index')->with('AllSongInfo', $AllSongInfo)->with('AllVideosInfo', $AllVideosInfo)->with('LastVideo', $LastVideo);
 }
 public function getVideo($year = null)
 {
     settype($year, 'integer');
     if (preg_match('/\\d{4}/', $year)) {
         return Videos::where('year', '=', $year)->get();
     }
 }
 public function delete(Request $request)
 {
     if (!ACL::hasPermission('videos', 'delete')) {
         return redirect(route('videos'))->withErrors(['Você não tem permissão para deletar vídeos.']);
     }
     Videos::find($request->get('videosId'))->delete();
     $success = "Vídeo excluído com sucesso.";
     return redirect(route('videos'))->with(compact('success'));
 }
 public function delete(Request $request)
 {
     if (!ACL::hasPermission('participants', 'delete')) {
         return redirect(route('participants'))->withErrors(['Você não tem permissão para deletar participantes.']);
     }
     Photos::deletePhotosByUser($request->get('userId'));
     Videos::deleteVideosByUser($request->get('userId'));
     UsersReceipts::deleteReceiptsByUser($request->get('userId'));
     User::find($request->get('userId'))->delete();
     $success = "Participante excluído com sucesso.";
     return redirect(route('participants'))->with(compact('success'));
 }
 public function putDelete(Request $request)
 {
     if (!ACL::hasPermission('winners', 'delete')) {
         return redirect(url('/admin/vencedores#' . $request->table))->withErrors(['Você não tem permissão para excluir ' . $request->table . '.']);
     }
     if (isset($request->videosId)) {
         $videos = Videos::find($request->videosId);
         $videos->winner = 0;
         $videos->quantityVotes = "";
         $videos->save();
     } elseif (isset($request->photosId)) {
         $photos = Photos::find($request->photosId);
         $photos->winner = 0;
         $photos->quantityVotes = "";
         $photos->save();
     }
     $success = "Vencedor excluído com sucesso!";
     return redirect(url('/admin/vencedores#' . $request->table))->with(compact('success'));
 }
 public function index()
 {
     $page = 'finalistas';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     if ($websiteSettings['votingOk'] == 0) {
         $message = "A página que você tentou acessar está indisponível no momento ou não existe";
         return redirect('/')->with(compact('message'));
     }
     $pages = Pages::where('slug', '=', $page)->first();
     $advertising = Advertising::orderByRaw("RAND()")->get();
     foreach ($advertising as $ad) {
         array_add($ad, "image", Advertising::imageVideo($ad->url));
         array_set($ad, "url", Advertising::embedVideo($ad->url, 1));
     }
     $calls = Calls::orderByRaw("RAND()")->limit(2)->get();
     $finalistsPhotos = Photos::where('photos.status', '=', 2)->where('urlInstagram', '!=', '')->join('users', 'users.id', '=', 'photos.usersId')->addSelect('users.babyName')->addSelect('users.city')->addSelect('users.state')->addSelect('photos.usersId')->addSelect('photos.photo')->addSelect('photos.urlInstagram')->orderByRaw('RAND()')->get();
     $finalistsVideos = Videos::where('videos.status', '=', 2)->where('urlInstagram', '!=', '')->join('users', 'users.id', '=', 'videos.usersId')->addSelect('users.babyName')->addSelect('users.city')->addSelect('users.state')->addSelect('videos.url')->addSelect('videos.urlInstagram')->orderByRaw('RAND()')->get();
     foreach ($finalistsVideos as $wiVi) {
         array_add($wiVi, "image", Advertising::imageVideo($wiVi->url));
     }
     return view('website.finalists')->with(compact('page', 'websiteSettings', 'pages', 'advertising', 'calls', 'finalistsPhotos', 'finalistsVideos'));
 }
 public function VideoSeeder()
 {
     DB::table('videos')->delete();
     Videos::create(['video_url' => 'https://www.youtube.com/watch?v=wgMQxxLAphs', 'video_description' => 'Just trying to cover this awesome song', 'video_author' => 'Zizazao', 'video_name' => 'Hurt Cover', 'video_artist' => 'Johnny Cash', 'video_album' => 'American IV: The Man Comes Around']);
 }
 public function postUpload(Request $request)
 {
     if (!empty($request->file('photo')) or !empty($request->url)) {
         if (5 < count($request->file('photo'))) {
             $message = "Você enviou mais fotos do que o permitido!";
             return redirect(url('/'))->with(compact('message'));
         } else {
             $userId = Auth::user()->id;
             $quantityPhotos = Photos::quantityPhotosByUser($userId);
             $quantityVideos = Videos::quantityVideosByUser($userId);
             $quantityPhotosAvailable = 5 - $quantityPhotos;
             if ($quantityPhotosAvailable < count($request->file('photo'))) {
                 $message = "Você enviou mais fotos/vídeo do que o permitido!";
                 return redirect(url('/'))->with(compact('message'));
             } else {
                 $folder = 'assets/images/_upload/fotos/' . $userId . '/';
                 if (!File::exists($folder)) {
                     File::makeDirectory($folder, 0777);
                 }
                 if (!empty($request->url) and (substr_count($request->url, "http://") == 1 or substr_count($request->url, "https://") == 1) and $quantityVideos == 0) {
                     $videoAdd = new Videos();
                     $videoAdd->usersId = $userId;
                     $videoAdd->url = $request->url;
                     $videoAdd->save();
                 }
                 if (!empty($request->file('photo'))) {
                     foreach ($request->photo as $file) {
                         if (!is_null($file)) {
                             if ($file->getSize() > 2048000 or $file->getSize() == 0) {
                                 $message = "As fotos não podem ser maiores que 2Mb!";
                                 return redirect(url('/'))->with(compact('message'));
                             } else {
                                 $photoAdd = new Photos();
                                 $photoAdd->usersId = $userId;
                                 //IMAGE
                                 $extension = $file->getClientOriginalExtension();
                                 $nameImage = Carbon::now()->format('YmdHis') . "_" . rand(0, 999999) . "." . $extension;
                                 Image::make($file)->resize(800, null, function ($constraint) {
                                     $constraint->aspectRatio();
                                 })->save($folder . $nameImage);
                                 Image::make($file)->resize(null, 231, function ($constraint) {
                                     $constraint->aspectRatio();
                                 })->save($folder . "thumb_" . $nameImage);
                                 $photoAdd->photo = $nameImage;
                                 $photoAdd->save();
                             }
                         } else {
                             if (is_null($file) and empty($request->url)) {
                                 $message = "Envie pelo menos uma foto ou vídeo!";
                                 return redirect(url('/'))->with(compact('message'));
                             }
                         }
                     }
                 }
                 $message = "Mídias enviadas com sucesso!";
                 return redirect(url('/'))->with(compact('message'));
             }
         }
     } else {
         $message = "Envie pelo menos uma foto ou vídeo!";
         return redirect(url('/'))->with(compact('message'));
     }
 }
 public function updateVideos($id)
 {
     $title1 = 'Video';
     $title = 'Updated';
     $t = Videos::findOrFail($id);
     $t->fill(\Input::all());
     $t->save();
     return view('VideoUpdated')->with('title1', $title1)->with('title', $title);
 }
 public function displayVideo($id)
 {
     $videoName = Videos::where('id', $id)->first();
     $videoUrl = $videoName->video_url;
     $watchVideoTitle = Videos::where('id', $id)->pluck('video_name');
     $title1 = 'Watch';
     $title = $watchVideoTitle;
     $videoInfo = $videoName;
     return view('watchVideo')->with('videoInfo', $videoName)->with('title1', $title1)->with('title', $title)->with('videoUrl', $videoUrl);
 }
Exemple #11
0
 public function upvote($id)
 {
     if (Config('app.voting_on') || Auth::user()->admin == 1) {
         $video = Videos::where('id', '=', $id)->first();
         $video->voteSuffix = $video->videoRating != 1 ? "votes" : "vote";
         if (!(Auth::user()->admin == 1)) {
             if (null !== Session::get('user.votes')) {
                 if (count(Session::get('user.votes')) < 3) {
                     foreach (Session::get('user.votes') as $existingVote) {
                         if ($existingVote == $id) {
                             // Video previously voted for
                             return $video->videoRating . " " . $video->voteSuffix . " &ndash; You've already voted!";
                         }
                     }
                 } else {
                     return $video->videoRating . " " . $video->voteSuffix . " &ndash; You've run out of votes!";
                 }
             }
         }
         // Video not previously voted for
         Videos::where('id', '=', $id)->increment('videoRating');
         Session::push('user.votes', $id);
         $video = Videos::where('id', '=', $id)->first();
         $video->voteSuffix = $video->videoRating != 1 ? "votes" : "vote";
         return $video->videoRating . " " . $video->voteSuffix . " &ndash; Thanks for your vote!";
     }
 }
 public function videos($usersId)
 {
     return Videos::where('usersId', '=', $usersId);
 }