jenya
1 week ago

Remove attachment with laravel-medialibrary

Posted 1 week ago by jenya

Hello! I use spatie/laravel-medialibrary 7.19.13 package to manage my mediafiles (Laravel 5.8.38) Does this package have functionality :

a) To remove media file associations with model. For expamle, I have a Person model:

<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\HasMedia\HasMedia;

class Person extends Model implements HasMedia
{
    use HasMediaTrait;

I want to remove associations with Person model (not the files themselves), if I have array of attachments id's;

b) Remove file associations and files themselves from filesystem.

Thanks!

Please sign in or create an account to participate in this conversation.