PHP code example of nicklasos / laravel-admin-media-library

1. Go to this page and download the library: Download nicklasos/laravel-admin-media-library library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nicklasos / laravel-admin-media-library example snippets


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;
}

class MyModel extends Model implements HasMedia
{
    use InteractsWithMedia;

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

    public function setImageAttribute()
    {

    }
}