You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to ask you about the problem with deleting the model and all attached media to this model.
my model is:
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\Image\Manipulations;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
class Product extends Model implements HasMedia
{
use SoftDeletes;
use HasFactory;
use InteractsWithMedia;
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to ask you about the problem with deleting the model and all attached media to this model.
my model is:
from the doc: https://spatie.be/docs/laravel-medialibrary/v10/basic-usage/retrieving-media
When a Media instance gets deleted all related files will be removed from the filesystem.
Deleting a model with associated media will also delete all associated files. If you use soft deletes, the associated files won't be deleted.
$yourModel->delete(); // all associated files will be deleted as well
But when I try to delete my model via tinker like:
Product::find(5448)->delete();
Only the model is marked as deleted (column deleted_at is updated)
But all media still exist and all files are still on disk.
I tried to remove use SoftDeletes; but without result.
Thank you for your reply.
Docker env FROM php:8.0-fpm
composer packages:
"laravel/framework": "^9.0",
"spatie/laravel-medialibrary": "^10.0.0"
Beta Was this translation helpful? Give feedback.
All reactions