PHP code example of solution-forest / filament-panzoom
1. Go to this page and download the library: Download solution-forest/filament-panzoom 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/ */
solution-forest / filament-panzoom example snippets
use SolutionForest\FilamentPanzoom\FilamentPanzoomPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
// ... other configuration
->plugins([
FilamentPanzoomPlugin::make(),
// ... other plugins
]);
}
// Forms, Actions & Tables
use SolutionForest\FilamentPanzoom\Components\PanZoom;
public static function form(Form $form): Form
{
return $form->schema([
PanZoom::make('image_preview')
->imageUrl(fn ($record) => $record?->image_url)
->label('Image Preview')
->columnSpanFull(),
]);
}
// Infolists
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
public function infolist(Infolist $infolist): Infolist
{
return $infolist->schema([
PanZoomEntry::make('image_preview')
->imageUrl(fn ($record) => $record?->image_url)
->label('Image Preview'),
]);
}
// Forms - Uses Schemas
use SolutionForest\FilamentPanzoom\Components\PanZoom;
public static function configure(Schema $schema): Schema
{
return $schema->components([
PanZoom::make('image_preview')
->imageUrl(fn ($record) => $record?->image_url),
// Note: label() and columnSpanFull() methods not available in 4.0+
]);
}
// Infolists - Uses Schemas
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
public static function configure(Schema $schema): Schema
{
return $schema->components([
PanZoomEntry::make('image_preview')
->imageUrl(fn ($record) => $record?->image_url),
]);
}
// Filament 3.0+ Forms
PanZoom::make('image_preview')
->imageUrl(fn ($record) => $record?->image_url)
->doubleClickZoomLevel(2.5) // Zoom to 2.5x instead of default 3x
->label('Image Preview');
// Filament 4.0+ Forms
PanZoom::make('image_preview')
->imageUrl(fn ($record) => $record?->image_url)
->doubleClickZoomLevel(4.0) // Zoom to 4x for more detail
->columnSpanFull();
// Infolists (both 3.0+ and 4.0+)
PanZoomEntry::make('image_preview')
->imageUrl(fn ($record) => $record?->image_url)
->doubleClickZoomLevel(2.0) // Zoom to 2x
->imageId(fn ($record) => 'image-' . $record->id);
public static function form(Form $form): Form
{
return $form->schema([
PanZoom::make('image_preview')
->imageUrl(fn ($record) => $record?->image_url)
->label('Image Preview')
->columnSpanFull(),
]);
}
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
public function infolist(Infolist $infolist): Infolist
{
return $infolist->schema([
PanZoomEntry::make('receipt_image')
->imageUrl(fn ($record) => asset('storage/' . $record->image_path))
->label('Receipt Image')
->imageId(fn ($record) => 'receipt-' . $record->id),
]);
}
public static function configure(Schema $schema): Schema
{
return $schema->components([
PanZoom::make('image_preview')
->imageUrl(fn ($record) => $record?->image_url),
// Note: label() and columnSpanFull() methods not available in 4.0+
]);
}
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
public static function configure(Schema $schema): Schema
{
return $schema->components([
PanZoomEntry::make('receipt_image')
->imageUrl(fn ($record) => asset('storage/' . $record->image_path))
->imageId(fn ($record) => 'receipt-' . $record->id),
]);
}
public static function table(Table $table): Table
{
return $table->actions([
Action::make('viewImage')
->form([
PanZoom::make('image_viewer')
->imageUrl(fn ($record) => $record->image_url),
])
]);
}
protected function getFormSchema(): array
{
return [
PanZoom::make('document_viewer')
->imageUrl($this->imageUrl),
// Note: columnSpanFull() method not available in 4.0+
];
}