63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Alsaloul\ImageGallery;
|
|
|
|
use Filament\Support\Assets\Css;
|
|
use Filament\Support\Assets\Js;
|
|
use Filament\Support\Facades\FilamentAsset;
|
|
use Spatie\LaravelPackageTools\Package;
|
|
use Spatie\LaravelPackageTools\PackageServiceProvider;
|
|
|
|
class ImageGalleryServiceProvider extends PackageServiceProvider
|
|
{
|
|
public static string $name = 'image-gallery';
|
|
|
|
public static string $viewNamespace = 'image-gallery';
|
|
|
|
public function configurePackage(Package $package): void
|
|
{
|
|
$package->name(static::$name)
|
|
->hasConfigFile()
|
|
->hasViews(static::$viewNamespace)
|
|
->hasTranslations();
|
|
}
|
|
|
|
public function packageBooted(): void
|
|
{
|
|
// Register assets
|
|
FilamentAsset::register(
|
|
$this->getAssets(),
|
|
$this->getAssetPackageName()
|
|
);
|
|
|
|
\Filament\Tables\Columns\ImageColumn::macro('imageGallery', function () {
|
|
$this->view('image-gallery::columns.image-column-gallery');
|
|
$this->disabledClick();
|
|
|
|
return $this;
|
|
});
|
|
|
|
\Filament\Infolists\Components\ImageEntry::macro('imageGallery', function () {
|
|
$this->view('image-gallery::infolists.entries.image-entry-gallery');
|
|
|
|
return $this;
|
|
});
|
|
}
|
|
|
|
protected function getAssetPackageName(): ?string
|
|
{
|
|
return 'al-saloul/filament-image-gallery';
|
|
}
|
|
|
|
/**
|
|
* @return array<\Filament\Support\Assets\Asset>
|
|
*/
|
|
protected function getAssets(): array
|
|
{
|
|
return [
|
|
Css::make('image-gallery-styles', __DIR__ . '/../resources/dist/image-gallery.css'),
|
|
Js::make('image-gallery-scripts', __DIR__ . '/../resources/dist/image-gallery.js'),
|
|
];
|
|
}
|
|
}
|