PHP code example of sweet1s / moonshine-filemanager

1. Go to this page and download the library: Download sweet1s/moonshine-filemanager 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/ */

    

sweet1s / moonshine-filemanager example snippets


// ...
use Sweet1s\MoonshineFileManager\FileManager;
use Sweet1s\MoonshineFileManager\FileManagerTypeEnum;

class PostResource extends ModelResource
{
    public function fields(): array
    {
        return [
                Block::make('Contact information', [
                    // ...
                    FileManager::make('Image', 'images')
                        ->typeOfFileManager(FileManagerTypeEnum::File) // By default is FileManagerTypeEnum::Image
                        ->title('Media Manager') // By default, is 'File Manager'
                        ->allowedExtensions(['pdf', 'doc', 'txt']) // By default, all extensions are allowed
                        ->removable() // By default is false
            ]),
        ];
    }
}

protected $casts = [ 'images' => 'collection', ];

//or

protected function casts(): array
{
    return [
        'images' => 'collection',
    ];
}