F
Filament12mo ago
d3v1anX

Access panel name globally or in scopes

Hey there, is it possible to access the actual panel globally somehow, or in a global scope? I want to add a global scope if I'm not on the admin panel
public function apply(Builder $builder, Model $model): void
{
// if(
!\Auth::user() || // for console commands
(
\Auth::user()->isSuperAdmin() // &&
// $panel->name == "admin" // <<<--- Somehow here
)
)
return;

$builder->whereHas('user', function (Builder $query) {
$query->where('company_id', \Auth::user()->company_id);
});

}
public function apply(Builder $builder, Model $model): void
{
// if(
!\Auth::user() || // for console commands
(
\Auth::user()->isSuperAdmin() // &&
// $panel->name == "admin" // <<<--- Somehow here
)
)
return;

$builder->whereHas('user', function (Builder $query) {
$query->where('company_id', \Auth::user()->company_id);
});

}
Solution:
Maybe Filament::getCurrentPanel()?
Jump to solution
2 Replies
Solution
Patrick Boivin
Patrick Boivin12mo ago
Maybe Filament::getCurrentPanel()?
Patrick Boivin
Patrick Boivin12mo ago
or more generally Filament::isServing()