diff --git a/README.md b/README.md index dae6e84..66862e8 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ This filament Plugin provides an easy and flexible way to add a customizable foo - [Installation](#installation) - [Usage](#usage) - [Configurations](#configurations) + - [Enable or Disable the Footer](#enable-or-disable-the-footer) - [Footer position](#footer-position) - [Custom sentence](#custom-sentence) - [Show GitHub version](#show-github-version) @@ -88,6 +89,20 @@ use Devonab\FilamentEasyFooter\EasyFooterPlugin; --- +### Enable or Disable the Footer + +You can **enable or disable the footer** entirely using the following configuration: + +```php +use Devonab\FilamentEasyFooter\EasyFooterPlugin; + +->plugins([ + EasyFooterPlugin::make() + ->footerEnabled() // true by default, +]); +``` +Without this configuration, the footer will be enabled by default. + ### Footer position You can choose the **position of the footer** by using this configuration : diff --git a/composer.json b/composer.json index 3173d0c..22b8272 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,8 @@ "keywords": [ "Devonab", "laravel", + "filament", + "filament-php", "filament-easy-footer" ], "homepage": "https://github.com/devonab/filament-easy-footer", @@ -15,7 +17,6 @@ "authors": [ { "name": " Devonab", - "email": "vable93@gmail.com", "role": "Developer" } ], diff --git a/src/EasyFooterPlugin.php b/src/EasyFooterPlugin.php index db2c7d4..584d970 100644 --- a/src/EasyFooterPlugin.php +++ b/src/EasyFooterPlugin.php @@ -41,6 +41,8 @@ class EasyFooterPlugin implements Plugin protected int $logoHeight = 20; + protected bool $isFooterEnabled = true; + /** * Get the unique identifier for the plugin */ @@ -56,7 +58,7 @@ public function getId(): string */ public function register(Panel $panel): void { - if ($this->shouldSkipRendering()) { + if ($this->shouldSkipRendering() || !$this->isFooterEnabled) { return; } @@ -76,6 +78,29 @@ public function register(Panel $panel): void ); } + + /** + * Enable or disable the footer completely + * using ->footerEnabled(true or false) + * + * @param bool $enabled Whether the footer should be displayed + */ + public function footerEnabled(bool $enabled = true): static + { + $this->isFooterEnabled = $enabled; + + return $this; + } + + /** + * Check if the footer is enabled + */ + public function isFooterEnabled(): bool + { + return $this->isFooterEnabled; + } + + /** * Check if the footer rendering should be skipped */ diff --git a/tests/Feature/FilamentPluginTest.php b/tests/Feature/FilamentPluginTest.php index 73b1b8a..2133c98 100644 --- a/tests/Feature/FilamentPluginTest.php +++ b/tests/Feature/FilamentPluginTest.php @@ -8,6 +8,38 @@ ->expect(fn () => EasyFooterPlugin::make()->getId()) ->toBe('filament-easy-footer'); +it('enables footer by default') + ->expect(fn () => EasyFooterPlugin::make()->isFooterEnabled()) + ->toBeTrue(); + +it('can disable footer', function () { + $plugin = EasyFooterPlugin::make() + ->footerEnabled(false); + + expect($plugin->isFooterEnabled())->toBeFalse(); +}); + +it('can enable footer explicitly', function () { + $plugin = EasyFooterPlugin::make() + ->footerEnabled(false) + ->footerEnabled(true); + + expect($plugin->isFooterEnabled())->toBeTrue(); +}); + +it('skips rendering when footer is disabled', function () { + $request = Mockery::mock(Request::class)->makePartial(); + $request->shouldReceive('path')->andReturn('admin/dashboard'); + app()->instance('request', $request); + + $plugin = EasyFooterPlugin::make() + ->footerEnabled(false); + + expect($plugin) + ->isFooterEnabled()->toBeFalse() + ->shouldSkipRendering()->toBeFalse(); +}); + it('shows footer by default', function () { $request = Mockery::mock(Request::class)->makePartial(); $request->shouldReceive('path')->andReturn('admin/dashboard');