Пример #1
0
 /**
  * A model has been deleted, trash all of it's files
  *
  * @param Illuminate\Database\Eloquent\Model $model 
  * @return void
  */
 public function onDeleted(Model $model)
 {
     // Check that the model supports uploads through Upchuck
     if (!$this->supportsUploads($model) || !($map = $model->getUploadMap())) {
         return;
     }
     // Loop through the all of the upload attributes ...
     foreach ($map as $key => $attribute) {
         if (!($path = $model->getAttribute($attribute))) {
             continue;
         }
         $this->storage->delete($path);
     }
 }
Пример #2
0
 /**
  * A model has been deleted, trash all of it's files
  *
  * @param Illuminate\Database\Eloquent\Model $model
  * @return void
  */
 public function onDeleted(Model $model)
 {
     // Check that the model supports uploads through Upchuck
     if (!$this->supportsUploads($model) || !($attributes = $model->getUploadAttributes())) {
         return;
     }
     // Loop through the all of the upload attributes and get the values using
     // "original" so that you get the file value before it may have been cleared.
     foreach ($attributes as $attribute) {
         if (!($url = $model->getOriginal($attribute))) {
             continue;
         }
         $this->storage->delete($url);
     }
 }
Пример #3
0
 /**
  * Duplicate a file given it's URL
  *
  * @param  string $url
  * @return string
  */
 public function duplicate($url)
 {
     // Make the destination path
     $current_path = $this->helpers->path($url);
     $filename = basename($current_path);
     $dst_disk = $this->disks ? $this->disks->getFilesystem('dst') : $this->disk;
     $new_path = $this->storage->makeNestedAndUniquePath($filename, $dst_disk);
     // Copy, supporting alternative destination disks
     if ($this->disks) {
         $this->disks->copy('src://' . $current_path, 'dst://' . $new_path);
     } else {
         $this->disk->copy($current_path, $new_path);
     }
     // Return the Upchuck URL
     return $this->helpers->url($new_path);
 }