PHP code example of filament / spatie-laravel-media-library-plugin
1. Go to this page and download the library: Download filament/spatie-laravel-media-library-plugin 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/ */
filament / spatie-laravel-media-library-plugin example snippets
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
SpatieMediaLibraryFileUpload::make('avatar')
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
SpatieMediaLibraryFileUpload::make('avatar')
->collection('avatars')
use Filament\Forms\Components\FileUpload;
FileUpload::make('attachment')
->disk('s3')
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
SpatieMediaLibraryFileUpload::make('attachments')
->multiple()
->reorderable()
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
SpatieMediaLibraryFileUpload::make('attachments')
->multiple()
->customProperties(['zip_filename_prefix' => 'folder/subfolder/'])
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
SpatieMediaLibraryFileUpload::make('attachments')
->multiple()
->customHeaders(['CacheControl' => 'max-age=86400'])
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
SpatieMediaLibraryFileUpload::make('attachments')
->multiple()
->responsiveImages()
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
SpatieMediaLibraryFileUpload::make('attachments')
->conversion('thumb')
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
SpatieMediaLibraryFileUpload::make('attachments')
->conversionsDisk('s3')
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
SpatieMediaLibraryFileUpload::make('attachments')
->multiple()
->manipulations([
'thumb' => ['orientation' => '90'],
])
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Filament\Forms\Get;
use Illuminate\Support\Collection;
SpatieMediaLibraryFileUpload::make('images')
->customProperties(fn (Get $get): array => [
'gallery_id' => $get('gallery_id'),
])
->filterMediaUsing(
fn (Collection $media, Get $get): Collection => $media->where(
'custom_properties.gallery_id',
$get('gallery_id')
),
)
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
SpatieMediaLibraryImageColumn::make('avatar')
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
SpatieMediaLibraryImageColumn::make('avatar')
->collection('avatars')
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
SpatieMediaLibraryImageColumn::make('avatar')
->allCollections()
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
SpatieMediaLibraryImageColumn::make('avatar')
->conversion('thumb')
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
use Illuminate\Support\Collection;
SpatieMediaLibraryImageColumn::make('images')
->filterMediaUsing(
fn (Collection $media): Collection => $media->where(
'custom_properties.gallery_id',
12345,
),
)
use Filament\Infolists\Components\SpatieMediaLibraryImageEntry;
SpatieMediaLibraryImageEntry::make('avatar')
use Filament\Infolists\Components\SpatieMediaLibraryImageEntry;
SpatieMediaLibraryImageEntry::make('avatar')
->collection('avatars')
use Filament\Infolists\Components\SpatieMediaLibraryImageEntry;
SpatieMediaLibraryImageEntry::make('avatar')
->allCollections()
use Filament\Infolists\Components\SpatieMediaLibraryImageEntry;
SpatieMediaLibraryImageEntry::make('avatar')
->conversion('thumb')
use Filament\Tables\Columns\SpatieMediaLibraryImageEntry;
use Illuminate\Support\Collection;
SpatieMediaLibraryImageEntry::make('images')
->filterMediaUsing(
fn (Collection $media): Collection => $media->where(
'custom_properties.gallery_id',
12345,
),
)
bash
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-migrations"
bash
php artisan migrate