public function postSentVideo(Request $request)
 {
     $video = Videos::where('usersId', '=', $request->userId)->addSelect('url')->get();
     foreach ($video as $vi) {
         array_add($vi, "image", Advertising::imageVideo($vi->url));
     }
     return json_encode($video);
 }
 public function delete(Request $request)
 {
     if (!ACL::hasPermission('advertising', 'delete')) {
         return redirect(route('advertising'))->withErrors(['Você não pode deletar propagandas.']);
     }
     Advertising::find($request->get('advertisingId'))->delete();
     $success = "Propaganda excluída com sucesso.";
     return redirect(route('advertising'))->with(compact('success'));
 }
 public function getFinalist($videosId)
 {
     if (!ACL::hasPermission('videos', 'edit')) {
         return redirect(route('videos'))->withErrors(['Você não tem permissão para editar o status dos vídeos.']);
     }
     $video = Videos::where('videos.videosId', '=', $videosId)->join('users', 'users.id', '=', 'videos.usersId')->orderBy('videos.created_at', 'DESC')->addSelect('videos.videosId')->addSelect('videos.created_at')->addSelect('videos.url')->addSelect('videos.urlInstagram')->addSelect('videos.status')->addSelect('users.id AS userId')->addSelect('users.babyName')->addSelect('users.name')->first();
     array_add($video, "image", Advertising::imageVideo($video->url));
     return view('admin.videos.finalist')->with(compact('video'));
 }
 public function getIndex()
 {
     if (!ACL::hasPermission('winners')) {
         return redirect(route('home'))->withErrors(['Você não tem permissão para acessar a página de vencedores.']);
     }
     $photoWinners = Photos::where('winner', '=', 1)->join('users', 'usersId', '=', 'id')->orderBy('quantityVotes', 'DESC')->addSelect('photosId')->addSelect('usersId')->addSelect('babyName')->addSelect('name')->addSelect('city')->addSelect('state')->addSelect('photo')->addSelect('quantityVotes')->get();
     $videoWinners = Videos::where('winner', '=', 1)->join('users', 'usersId', '=', 'id')->orderBy('quantityVotes', 'DESC')->addSelect('videosId')->addSelect('babyName')->addSelect('name')->addSelect('city')->addSelect('state')->addSelect('url')->addSelect('quantityVotes')->get();
     foreach ($videoWinners as $videoWinner) {
         array_add($videoWinner, "image", Advertising::imageVideo($videoWinner->url));
     }
     $qtdWinners = $photoWinners->count() + $videoWinners->count();
     return view('admin.winners.index')->with(compact('photoWinners', 'videoWinners', 'qtdWinners'));
 }
 public function index()
 {
     $page = 'ganhadores-2014';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     $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();
     $winners = WinnersLastYear::orderBy('winnersLastYearId', 'ASC')->get();
     return view('website.winners2014')->with(compact('page', 'websiteSettings', 'pages', 'advertising', 'calls', 'winners'));
 }
 public function index()
 {
     $page = 'o-concurso';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     $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();
     $theCompetition = TheCompetition::find(1);
     return view('website.theCompetition')->with(compact('page', 'websiteSettings', 'pages', 'advertising', 'calls', 'theCompetition'));
 }
 public function getView($usersId)
 {
     if (!ACL::hasPermission('participants')) {
         return redirect(route('participants'))->withErrors(['Você não tem permissão para visualizar dados dos participantes.']);
     }
     $user = User::where('id', '=', $usersId)->first();
     $photos = Photos::where('usersId', '=', $usersId)->get();
     $videos = Videos::where('usersId', '=', $usersId)->get();
     foreach ($videos as $video) {
         array_add($video, "image", Advertising::imageVideo($video->url));
         array_set($video, "url", Advertising::embedVideo($video->url, 1));
     }
     $usersReceipts = UsersReceipts::where('usersId', '=', $usersId)->get();
     return view('admin.participants.view')->with(compact('user', 'photos', 'videos', 'usersReceipts'));
 }
 public function getResetWebsite($token = null)
 {
     $page = 'recuperar-senha';
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     $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();
     if (is_null($token)) {
         throw new NotFoundHttpException();
     }
     return view('website.recoveryPassword')->with(compact('token', 'page', 'websiteSettings', 'pages', 'advertising', 'calls', 'awards'));
 }
 public function index()
 {
     $page = 'contato';
     //WEBSITE SETTINGS
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     //STATES
     $statesConsult = \App\Exceptions\Handler::readFile("states.json");
     $states = ['' => 'UF'];
     foreach ($statesConsult as $state) {
         $states[$state['uf']] = $state['uf'];
     }
     $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();
     return view('website.contact')->with(compact('page', 'websiteSettings', 'pages', 'advertising', 'calls', 'states'));
 }
 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 index()
 {
     $page = 'inscricao';
     //WEBSITE SETTINGS
     $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json");
     if ($websiteSettings['registerOk'] == 0) {
         $message = "A página que você tentou acessar está indisponível no momento ou não existe";
         return redirect('/')->with(compact('message'));
     }
     //STATES
     $statesConsult = \App\Exceptions\Handler::readFile("states.json");
     $states = ['' => 'UF'];
     foreach ($statesConsult as $state) {
         $states[$state['uf']] = $state['uf'];
     }
     $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();
     return view('website.registration')->with(compact('page', 'websiteSettings', 'pages', 'advertising', 'calls', 'states'));
 }