spatie-laravel-media-library-plugin creates Media model and then deletes afterwards

Hi everyone,

I am trying the spatie-laravel-media-library-plugin plugin from the Filament team. I have added it to my resource:

SpatieMediaLibraryFileUpload::make('trip_image')
       ->collection('default')
       ->translateLabel()


As per documentation. It has two conversions.

The uploading works, when I save I see in Clockworks (similar to debugbar) that the media is created in the database along with the conversions:

Media    
INSERT INTO `media` (
    `name`,
    `file_name`,
    `DISK`,
    `conversions_disk`,
    `collection_name`,
    `mime_type`,
    `size`,
    `custom_properties`,
    `generated_conversions`,
    `responsive_images`,
    `manipulations`,
    `model_id`,
    `model_type`,
    `uuid`,
    `order_column`,
    `updated_at`,
    `created_at`
  )
VALUES (
    'pexels-photo-1884574 (1)',
    'YZSVoTAZjoZ3g3XNxGsnrWjQtLj6Fu-metacGV4ZWxzLXBob3RvLTE4ODQ1NzQgKDEpLmpwZWc=-.jpg',
    'public',
    'public',
    'default',
    'image/jpeg',
    126725,
    '[]',
    '[]',
    '[]',
    '[]',
    4,
    'Domain\\Trips\\Models\\Trip',
    'fab0db9b-fc51-4a19-b988-5c9da102af0f',
    1,
    '2023-08-16 08:33:27',
    '2023-08-16 08:33:27'
  )
FileAdder.php:441
3.27 ms
Media    
UPDATE `media`
SET `generated_conversions` = '{\"trip-item\":true}',
  `media`.`updated_at` = '2023-08-16 08:33:27'
WHERE `id` = 8
Media.php:459
4.57 ms
Media    
UPDATE `media`
SET `generated_conversions` = '{\"trip-item\":true,\"trip-page\":true}',
  `media`.`updated_at` = '2023-08-16 08:33:27'
WHERE `id` = 8


Then, a bit later, it deletes it:

DELETE FROM `media`
WHERE `id` = 8


I have no clue why, and I also don't get any errors logged anywhere. Is there anyone who encountered this before and managed to fix this? Thanks!
Was this page helpful?