Skip to content

nicklasos/laravel-admin-media-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spatie Media-Library extension for Laravel-Admin

Install

composer require nicklasos/laravel-admin-media-library

Usage

protected function form()
{
    $form = new Form(new MyModel);

    // Single media
    $form->mediaLibrary('image', 'Image')
        ->responsive()
        ->removable();

    // Multiple media field
    $form->multipleMediaLibrary('photos', 'Photos')
        ->responsive()
        ->removable();

    return $form;
}

Note: you have to add setPhotosAttribute and setImageAttribute methods to your model:

class MyModel extends Model implements HasMedia
{
    use InteractsWithMedia;

    public function setPhotosAttribute()
    {
        // you can leave it empty
    }

    public function setImageAttribute()
    {

    }
}

Thanks to luischavez/laravel-admin-media-library for code samples.