visual-ideas/moonshine-spatie-medialibrary

Spatie\MediaLibrary field for MoonShine Laravel admin panel
18,654 20
Install
composer require visual-ideas/moonshine-spatie-medialibrary
Latest Version:4.1.0
PHP:^8.1|^8.2|^8.3|^8.4
License:MIT
Last Updated:Jan 19, 2026
Links: GitHub  ·  Packagist
Maintainer: AlexVenga

Spatie\MediaLibrary field for MoonShine Laravel admin panel

Latest Version on Packagist Total Downloads

Compatibility

MoonShine Moonshine Spatie Medialibrary Currently supported
>= v1.52 and < v2.0 <= v1.2.0 no
>= v2.0 >= v2.0.1 yes
>= v3.0 >= v3.0.0 yes
>= v4.0 >= v4.0.0 yes

Installation

The field is purposed for work with the Laravel-MediaLibrary package made by Spatie and extends default field Image

composer require visual-ideas/moonshine-spatie-medialibrary

Before using the Spatie\MediaLibrary field, make sure that:

  • The spatie/laravel-medialibrary package is installed and configured
  • The visual-ideas/moonshine-spatie-medialibrary package is installed
  • The field passed to Spatie\MediaLibrary is added as the name of the collection via ->addMediaCollection('Field')

In the model:

use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
 
class ModelClass extends Model implements HasMedia
{
    use InteractsWithMedia;
 
    //...
    
    public function registerMediaCollections(): void
    {
        $this->addMediaCollection('cover');
    }
    
    //...
}

In the MoonShine:

use VI\MoonShineSpatieMediaLibrary\Fields\MediaLibrary;

//...

MediaLibrary::make('Cover', 'cover'),

//...

By default, the field works in a single image mode

use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
 
class ModelClass extends Model implements HasMedia
{
    use InteractsWithMedia;
    
    //...
    
    public function registerMediaCollections(): void
    {
        $this->addMediaCollection('cover')->singleFile();
    }
    
    //...
}

If you want to use a field to load multiple images, add the ->multiple() method when declaring the field

use VI\MoonShineSpatieMediaLibrary\Fields\MediaLibrary;

//...

MediaLibrary::make('Gallery', 'gallery')->multiple(),

//...

Related Packages

dialloibrahima/laravel-model-media

A lightweight trait for managing media files directly on your Eloquent models, w...

67 12
spescina/mediabrowser

Laravel packages that provide a basic user interface for browsing a server folde...

575 14
spatie/laravel-medialibrary

Associate files with Eloquent models

45,713,789 6,158
antennaio/laravel-clyde

Image uploads and manipulation for Laravel, a wrapper around Glide

2,621 29
indiesoft/laravel-uploads

Package to enable uploads for your models in a modern way.

80 1