Esempio n. 1
0
 public function GetSlugAttribute()
 {
     if (env('IMAGE_GET') == 'local') {
         $files = \File::allFiles(storage_path('app/accountancy/' . $this->id));
         return implode('|', $files);
     } else {
         $files = Photos::where('slug', 'like', 'accountancy%')->where('photo_id', $this->id)->get();
         return $files;
     }
 }
Esempio n. 2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     //
     foreach ($this->model->photos as $photo) {
         $oldfilename = storage_path('app') . $photo->slug;
         $newname = '/img/photos/' . $photo->id . '/' . $this->imageName;
         $newfilename = storage_path('app') . $newname;
         rename($oldfilename, $newfilename);
         $currentPhoto = Photos::find($photo->id);
         $currentPhoto->update(['slug' => $newname]);
     }
 }
 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 delete(Request $request)
 {
     if (!ACL::hasPermission('photos', 'delete')) {
         return redirect(route('photos'))->withErrors(['Você não tem permissão para deletar fotos.']);
     }
     if ($request->photo != "") {
         if (File::exists($this->folder . $request->usersId . '/thumb_' . $request->photo)) {
             File::delete($this->folder . $request->usersId . '/thumb_' . $request->photo);
         }
         if (File::exists($this->folder . $request->usersId . '/' . $request->photo)) {
             File::delete($this->folder . $request->usersId . '/' . $request->photo);
         }
     }
     Photos::find($request->get('photosId'))->delete();
     $success = "Foto excluída com sucesso.";
     return redirect(route('photos'))->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 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'));
     }
 }
Esempio n. 8
0
 public function sort()
 {
     foreach (\Input::get('photo') as $key => $id) {
         Photos::find($id)->update(['line' => $key]);
     }
     \Activity::log('Fotoğrafların Sıralaması Değiştirildi');
 }
Esempio n. 9
0
 public function ScopeSimilar($query, $photo_type, $photo_id)
 {
     $match = ['photo_type' => $photo_type, 'photo_id' => $photo_id];
     return Photos::where($match)->get();
 }
Esempio n. 10
0
 public function photos($usersId)
 {
     return Photos::where('usersId', '=', $usersId);
 }