예제 #1
0
 public function destroy($year, $month, $day)
 {
     $date = $this->createDate($year, $month, $day);
     $photo = new Photo($date);
     if ($photo->exists() === false) {
         abort(404);
     }
     $photo->delete();
     return response()->json($photo);
 }
예제 #2
0
 public function multiple_upload(Request $request)
 {
     /*
      * Tests incoming files to make sure there's no duplicates in db
      */
     // getting all of the post data
     $files = Input::file('userfile');
     // Making counting of uploaded images
     $file_count = count($files);
     // start count how many uploaded
     $uploadcount = 0;
     $hash_type = 'md5';
     // don't change this on an existing database!
     $filepath = 'img/';
     $thumbpath = 'img/thumbs/';
     foreach ($files as $file) {
         if (in_array(exif_imagetype($file), array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
             $filename = $file->getClientOriginalName();
             $extension = strtolower($file->getClientOriginalExtension());
             $photo = new Photo();
             //photo db object
             $photo->filename = $filename;
             $photo->extension = $extension;
             $photo->save();
             $currImg = Image::make($file);
             $currFilePath = $filepath . $photo->id . "." . $extension;
             $currImg->orientate()->save($currFilePath);
             // saving the actual file
             $hashcheck = hash_file($hash_type, $currFilePath);
             $hasDuplicate = Photo::where('hash', $hashcheck)->first();
             if ($hasDuplicate) {
                 // rollback if duplicate found
                 File::delete($currFilePath);
                 $photo->delete();
             } else {
                 $currImg->heighten(174)->save($thumbpath . $photo->id . "_thumb" . "." . $extension);
                 $photo->hash = hash_file($hash_type, $currFilePath);
                 // hash generated after we save the file
                 $photo->notes = $request->input('note');
                 $photo->image_subject = "Rosemary";
                 $photo->save();
                 $uploadcount++;
             }
             $currImg->destroy();
             // free up memory
         }
     }
     return $file_count - $uploadcount;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param $id
  * @return Response
  */
 public function destroy(Photo $photo)
 {
     $photo->delete();
 }
예제 #4
0
 public function deleteFile(Photo $photo)
 {
     @unlink(public_path() . $photo->path);
     $photo->delete();
 }
예제 #5
0
 public function destroy(Blog $blog, BlogPost $blogPost, Photo $photo)
 {
     $photo->delete();
     return back();
 }