/** * 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); } }
/** * 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); } }