We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling model->delete() does not clear images in storage. Have to call clearMediaCollection() before calling delete() on model.
class Item extends Model implements HasMedia { use HasFactory, InteractsWithMedia, HasSlug; public function registerMediaConversions(?Media $media = null): void { $this->addMediaConversion('thumbnail') ->width(368) ->height(232) ->sharpen(10) ->nonQueued(); } } $item = Item::factory()->create([]); $image = fake()->image(dir: storage_path('app/public/items'), width: 1024, height: 1024, category: 'flowers'); $item->addMedia($image)->preservingOriginal()->toMediaCollection();
Not working:
$item->delete();
public> php artisan media-library:clean Output: Orphaned media directory `1` has been removed
Working:
$item->clearMediaCollection(); $item->delete();
public> php artisan media-library:clean Output: All done!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Calling model->delete() does not clear images in storage. Have to call clearMediaCollection() before calling delete() on model.
Not working:
Working:
The text was updated successfully, but these errors were encountered: