Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 :
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"keywords": [
"Devonab",
"laravel",
"filament",
"filament-php",
"filament-easy-footer"
],
"homepage": "https://github.com/devonab/filament-easy-footer",
Expand All @@ -15,7 +17,6 @@
"authors": [
{
"name": " Devonab",
"email": "vable93@gmail.com",
"role": "Developer"
}
],
Expand Down
27 changes: 26 additions & 1 deletion src/EasyFooterPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class EasyFooterPlugin implements Plugin

protected int $logoHeight = 20;

protected bool $isFooterEnabled = true;

/**
* Get the unique identifier for the plugin
*/
Expand All @@ -56,7 +58,7 @@ public function getId(): string
*/
public function register(Panel $panel): void
{
if ($this->shouldSkipRendering()) {
if ($this->shouldSkipRendering() || !$this->isFooterEnabled) {
return;
}

Expand All @@ -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
*/
Expand Down
32 changes: 32 additions & 0 deletions tests/Feature/FilamentPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Loading