Skip to content

Commit 7e8907d

Browse files
fix
1 parent 84fd12a commit 7e8907d

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/FilamentEnvironment.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace LearnKit\FilamentEnvironment;
4+
5+
class FilamentEnvironment
6+
{
7+
public static $closure = null;
8+
9+
public static function gate($closure): void
10+
{
11+
static::$closure = $closure;
12+
}
13+
14+
public static function allows(): bool
15+
{
16+
if (static::$closure === null) {
17+
return true;
18+
}
19+
20+
$method = static::$closure;
21+
22+
return $method() ?? false;
23+
}
24+
}

src/FilamentEnvironmentServiceProvider.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public function register()
1818
public function boot()
1919
{
2020
Filament::serving(function () {
21-
Filament::registerRenderHook(PanelsRenderHook::BODY_START, fn() => view('filament-environment::bar'));
21+
if (FilamentEnvironment::allows()) {
22+
Filament::registerRenderHook(PanelsRenderHook::BODY_START, fn() => view('filament-environment::bar'));
23+
}
2224
});
2325
}
24-
}
26+
}

0 commit comments

Comments
 (0)