F
Filament14mo ago
Sandeep

How to set warning on header?

I required to display warning on header for free plan. #alert #warning
No description
Solution:
This might help: ```php use Illuminate\Contracts\View\View; use Filament\Support\Facades\FilamentView; ...
Jump to solution
8 Replies
Dennis Koch
Dennis Koch14mo ago
Is this even inside Filament panel?
Sandeep
SandeepOP14mo ago
Yes
Dennis Koch
Dennis Koch14mo ago
Are those custom pages? I guess you can inject that somewhere with a render hook. Maybe have a look at #impersonate which injects a banner, too, but at the top
Solution
ModestasV
ModestasV14mo ago
This might help:
use Illuminate\Contracts\View\View;
use Filament\Support\Facades\FilamentView;

class AppServiceProvider extends ServiceProvider
{
// ...

public function boot(): void
{
FilamentView::registerRenderHook(
'panels::page.start',
fn (): View => view('warning-banner')
);
}
}
use Illuminate\Contracts\View\View;
use Filament\Support\Facades\FilamentView;

class AppServiceProvider extends ServiceProvider
{
// ...

public function boot(): void
{
FilamentView::registerRenderHook(
'panels::page.start',
fn (): View => view('warning-banner')
);
}
}
Then your view:
<div class="mt-3 px-4 py-2 bg-primary-500/10 text-danger-600">
Sensitive orders.
</div>
<div class="mt-3 px-4 py-2 bg-primary-500/10 text-danger-600">
Sensitive orders.
</div>
Sandeep
SandeepOP14mo ago
Okay, I will try. Thanks It's working, but how to add warning icon and set to particular panel?
ModestasV
ModestasV14mo ago
You can surround it with if(Filament::getCurrentPanel()->getId() === 'somename'){ And for the icon - that's the simple Blade file, so you can place anything in there
Sandeep
SandeepOP14mo ago
Okay, sure. I will try. Thanks a lot
Sandeep
SandeepOP14mo ago
In this, it's take app as default. As I have two pannels app and admin. I want show alert to app only which for member or end user. This solution is not work for me in this scenario. So I have handled this thing by middle ware. Thanks a lot for idea and solutions.
Want results from more Discord servers?
Add your server