예제 #1
0
 /**
  * Handle the event.
  *
  * @param SavedArtist $event
  */
 public function handle(SavedArtist $event)
 {
     if ($file = $this->file) {
         // Set Image Full Size Name
         $filename = $this->image->setName($file);
         // Set Image Medium Size Name
         $filename_medium = $this->image->setName($file, 'medium');
         // Set Image Medium Size Name
         $filename_thumbnail = $this->image->setName($file, 'thumbnail');
         // Paths
         $imagesPath = public_path() . '/images/artists';
         $artistPath = $imagesPath . '/' . str_replace(' ', '', $event->artist->permalink);
         // Make Artist Directory
         $this->directory->make($artistPath);
         // Delete images if exists
         if (File::exists($artistPath)) {
             // Delete full size image
             $this->image->delete($artistPath, $event->artist->image);
             // Delete Image Medium Size
             $this->image->delete($artistPath, $event->artist->image_medium);
             // Delete Image Thumbnail Size
             $this->image->delete($artistPath, $event->artist->image_thumbnail);
         }
         // Make and upload full image size to artist path
         $this->image->make($file, 1024, $artistPath, $filename);
         // Make and upload full medium image size to artist path
         $this->image->make($file, 960, $artistPath, $filename_medium);
         // Make and upload full thumbnail image size to artist path
         $this->image->make($file, 480, $artistPath, $filename_thumbnail);
         // Update Artist resource image attributes
         $event->artist->update(['image' => $filename, 'image_medium' => $filename_medium, 'image_thumbnail' => $filename_thumbnail]);
     }
 }
예제 #2
0
 /**
  * Handle the event.
  *
  * @param  DeletedArtistEvent  $event
  * @return void
  */
 public function handle(DeletedArtist $event)
 {
     $path = public_path() . '/images/artists';
     $directory = $event->artist->permalink;
     $image_full = $event->artist->image;
     $image_medium = $event->artist->image_medium;
     $image_thumbnail = $event->artist->image_thumbnail;
     if (File::exists("{$path}/{$directory}")) {
         // Delete Images
         $this->image->delete($path, $directory . '/' . $image_full);
         $this->image->delete($path, $directory . '/' . $image_medium);
         $this->image->delete($path, $directory . '/' . $image_thumbnail);
         // Delete directory
         $this->directory->delete("{$path}/{$directory}");
     }
 }
예제 #3
0
 /**
  * Handle the event.
  *
  * @param  DeletedPost  $event
  * @return void
  */
 public function handle(DeletedNotice $event)
 {
     $path = public_path() . '/images/news';
     $noticePath = $path . '/' . $event->notice->permalink;
     $imageLarge = $event->notice->image_large;
     $imageMedium = $event->notice->image_medium;
     $imageThumbnail = $event->notice->image_thumbnail;
     if (File::exists($noticePath)) {
         // Delete Images
         $this->image->delete($noticePath, $imageLarge);
         $this->image->delete($noticePath, $imageMedium);
         $this->image->delete($noticePath, $imageThumbnail);
         // Check if there is files into category directory
         if ($this->directory->filesEmpty($noticePath)) {
             // Delete post directory
             $this->directory->delete($noticePath);
         }
     }
 }
예제 #4
0
 /**
  * Handle the event.
  *
  * @param  DeletedPost  $event
  * @return void
  */
 public function handle(DeletedPost $event)
 {
     $path = public_path() . '/images/posts';
     $postPath = $path . '/' . $event->post->permalink;
     $imageLarge = $event->post->image;
     $imageMedium = $event->post->image_medium;
     $imageThumbnail = $event->post->image_thumbnail;
     if (File::exists($postPath)) {
         // Delete Images
         $this->image->delete($postPath, $imageLarge);
         $this->image->delete($postPath, $imageMedium);
         $this->image->delete($postPath, $imageThumbnail);
         // Check if there is files into category directory
         // if for some reason can't delete files
         if ($this->directory->filesEmpty($postPath)) {
             // Delete post directory
             $this->directory->delete($postPath);
         }
     }
 }
예제 #5
0
 /**
  * Elimina un usuario de la base de datos.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id, Image $image, Directory $directory)
 {
     $user = User::findOrFail($id);
     // Paths
     $imagesPath = public_path() . '/images/users';
     $userPath = $imagesPath . '/' . str_replace(' ', '', $user->username);
     // Delete images if exists
     if (File::exists($userPath)) {
         // Delete image full size
         $image->delete($userPath, $user->image);
         // Delete image medium size
         $image->delete($userPath, $user->image_medium);
         // Delete image thumbnail size
         $image->delete($userPath, $user->image_thumbnail);
         $directory->delete($userPath);
     }
     $user->delete();
     session()->flash('message', 'Se Eliminó el Usuario "' . $user->name . '" Satisfactoriamente');
     return redirect()->route('admin.users.index');
 }