PHP code example of yojnc / moonshine-spatie-medialibrary
1. Go to this page and download the library: Download yojnc/moonshine-spatie-medialibrary 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/ */
yojnc / moonshine-spatie-medialibrary example snippets
composer
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
class ModelClass extends Model implements HasMedia
{
use InteractsWithMedia;
//...
public function registerMediaCollections(): void
{
$this->addMediaCollection('cover');
}
//...
}
use VI\MoonShineSpatieMediaLibrary\Fields\MediaLibrary;
//...
MediaLibrary::make('Cover', 'cover'),
//...
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
class ModelClass extends Model implements HasMedia
{
use InteractsWithMedia;
//...
public function registerMediaCollections(): void
{
$this->addMediaCollection('cover')->singleFile();
}
//...
}
use VI\MoonShineSpatieMediaLibrary\Fields\MediaLibrary;
//...
MediaLibrary::make('Gallery', 'gallery')->multiple(),
//...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.