mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
fix: Do not return default panel as current automatically
This commit is contained in:
@@ -12,7 +12,7 @@ class Topbar extends Page
|
||||
public function mount()
|
||||
{
|
||||
filament()
|
||||
->getCurrentPanel()
|
||||
->getCurrentPanelOrDefault()
|
||||
->userMenuItems([
|
||||
MenuItem::make()
|
||||
->label('Settings')
|
||||
|
||||
@@ -113,7 +113,7 @@ class Cluster extends Page
|
||||
|
||||
public static function getRouteName(?string $panel = null): string
|
||||
{
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanel();
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanelOrDefault();
|
||||
|
||||
return $panel->generateRouteName(static::getRelativeRouteName());
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class MakeUserCommand extends Command
|
||||
{
|
||||
$this->options = $this->options();
|
||||
|
||||
if (! Filament::getCurrentPanel()) {
|
||||
if (! Filament::getCurrentPanelOrDefault()) {
|
||||
$this->error('Filament has not been installed yet: php artisan filament:install --panels');
|
||||
|
||||
return static::FAILURE;
|
||||
|
||||
@@ -3,17 +3,5 @@
|
||||
namespace Filament\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class NoDefaultPanelSetException extends Exception
|
||||
{
|
||||
final public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public static function make(): static
|
||||
{
|
||||
return new static('No default Filament panel is set. You may do this with the `default()` method inside a Filament provider\'s `panel()` configuration.');
|
||||
}
|
||||
}
|
||||
class NoDefaultPanelSetException extends Exception {}
|
||||
|
||||
@@ -41,6 +41,7 @@ use Illuminate\Support\Facades\Facade;
|
||||
* @method static string getCollapsedSidebarWidth()
|
||||
* @method static string getCurrentDomain(?string $testingDomain = null)
|
||||
* @method static Panel | null getCurrentPanel()
|
||||
* @method static Panel | null getCurrentPanelOrDefault()
|
||||
* @method static string | Htmlable | null getDarkModeBrandLogo()
|
||||
* @method static string | null getDatabaseNotificationsPollingInterval()
|
||||
* @method static string getDefaultAvatarProvider()
|
||||
|
||||
@@ -56,7 +56,7 @@ class FilamentManager
|
||||
|
||||
public function auth(): Guard
|
||||
{
|
||||
return $this->getCurrentPanel()->auth();
|
||||
return $this->getCurrentPanelOrDefault()->auth();
|
||||
}
|
||||
|
||||
public function bootCurrentPanel(): void
|
||||
@@ -65,7 +65,7 @@ class FilamentManager
|
||||
return;
|
||||
}
|
||||
|
||||
$this->getCurrentPanel()->boot();
|
||||
$this->getCurrentPanelOrDefault()->boot();
|
||||
|
||||
$this->isCurrentPanelBooted = true;
|
||||
}
|
||||
@@ -75,37 +75,45 @@ class FilamentManager
|
||||
*/
|
||||
public function buildNavigation(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->buildNavigation();
|
||||
return $this->getCurrentPanelOrDefault()->buildNavigation();
|
||||
}
|
||||
|
||||
public function getAuthGuard(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getAuthGuard();
|
||||
return $this->getCurrentPanelOrDefault()->getAuthGuard();
|
||||
}
|
||||
|
||||
public function getAuthPasswordBroker(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getAuthPasswordBroker();
|
||||
return $this->getCurrentPanelOrDefault()->getAuthPasswordBroker();
|
||||
}
|
||||
|
||||
public function getBrandName(): string | Htmlable
|
||||
{
|
||||
return $this->getCurrentPanel()->getBrandName();
|
||||
return $this->getCurrentPanelOrDefault()->getBrandName();
|
||||
}
|
||||
|
||||
public function getBrandLogo(): string | Htmlable | null
|
||||
{
|
||||
return $this->getCurrentPanel()->getBrandLogo();
|
||||
return $this->getCurrentPanelOrDefault()->getBrandLogo();
|
||||
}
|
||||
|
||||
public function getBrandLogoHeight(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getBrandLogoHeight();
|
||||
return $this->getCurrentPanelOrDefault()->getBrandLogoHeight();
|
||||
}
|
||||
|
||||
public function getCollapsedSidebarWidth(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getCollapsedSidebarWidth();
|
||||
return $this->getCurrentPanelOrDefault()->getCollapsedSidebarWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NoDefaultPanelSetException
|
||||
*/
|
||||
public function getCurrentPanelOrDefault(): ?Panel
|
||||
{
|
||||
return $this->getCurrentPanel() ?? app(PanelRegistry::class)->getDefault();
|
||||
}
|
||||
|
||||
public function getCurrentPanel(): ?Panel
|
||||
@@ -115,17 +123,17 @@ class FilamentManager
|
||||
|
||||
public function getDarkModeBrandLogo(): string | Htmlable | null
|
||||
{
|
||||
return $this->getCurrentPanel()->getDarkModeBrandLogo();
|
||||
return $this->getCurrentPanelOrDefault()->getDarkModeBrandLogo();
|
||||
}
|
||||
|
||||
public function getDatabaseNotificationsPollingInterval(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getDatabaseNotificationsPollingInterval();
|
||||
return $this->getCurrentPanelOrDefault()->getDatabaseNotificationsPollingInterval();
|
||||
}
|
||||
|
||||
public function getDefaultAvatarProvider(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getDefaultAvatarProvider();
|
||||
return $this->getCurrentPanelOrDefault()->getDefaultAvatarProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,82 +149,82 @@ class FilamentManager
|
||||
*/
|
||||
public function getEmailVerificationPromptUrl(array $parameters = []): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getEmailVerificationPromptUrl($parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getEmailVerificationPromptUrl($parameters);
|
||||
}
|
||||
|
||||
public function getEmailVerifiedMiddleware(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getEmailVerifiedMiddleware();
|
||||
return $this->getCurrentPanelOrDefault()->getEmailVerifiedMiddleware();
|
||||
}
|
||||
|
||||
public function getFavicon(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getFavicon();
|
||||
return $this->getCurrentPanelOrDefault()->getFavicon();
|
||||
}
|
||||
|
||||
public function getFontFamily(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getFontFamily();
|
||||
return $this->getCurrentPanelOrDefault()->getFontFamily();
|
||||
}
|
||||
|
||||
public function getMonoFontFamily(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getMonoFontFamily();
|
||||
return $this->getCurrentPanelOrDefault()->getMonoFontFamily();
|
||||
}
|
||||
|
||||
public function getSerifFontFamily(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getSerifFontFamily();
|
||||
return $this->getCurrentPanelOrDefault()->getSerifFontFamily();
|
||||
}
|
||||
|
||||
public function getFontHtml(): Htmlable
|
||||
{
|
||||
return $this->getCurrentPanel()->getFontHtml();
|
||||
return $this->getCurrentPanelOrDefault()->getFontHtml();
|
||||
}
|
||||
|
||||
public function getMonoFontHtml(): Htmlable
|
||||
{
|
||||
return $this->getCurrentPanel()->getMonoFontHtml();
|
||||
return $this->getCurrentPanelOrDefault()->getMonoFontHtml();
|
||||
}
|
||||
|
||||
public function getSerifFontHtml(): Htmlable
|
||||
{
|
||||
return $this->getCurrentPanel()->getSerifFontHtml();
|
||||
return $this->getCurrentPanelOrDefault()->getSerifFontHtml();
|
||||
}
|
||||
|
||||
public function getFontProvider(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getFontProvider();
|
||||
return $this->getCurrentPanelOrDefault()->getFontProvider();
|
||||
}
|
||||
|
||||
public function getMonoFontProvider(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getMonoFontProvider();
|
||||
return $this->getCurrentPanelOrDefault()->getMonoFontProvider();
|
||||
}
|
||||
|
||||
public function getSerifFontProvider(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getSerifFontProvider();
|
||||
return $this->getCurrentPanelOrDefault()->getSerifFontProvider();
|
||||
}
|
||||
|
||||
public function getFontUrl(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getFontUrl();
|
||||
return $this->getCurrentPanelOrDefault()->getFontUrl();
|
||||
}
|
||||
|
||||
public function getMonoFontUrl(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getMonoFontUrl();
|
||||
return $this->getCurrentPanelOrDefault()->getMonoFontUrl();
|
||||
}
|
||||
|
||||
public function getSerifFontUrl(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getSerifFontUrl();
|
||||
return $this->getCurrentPanelOrDefault()->getSerifFontUrl();
|
||||
}
|
||||
|
||||
public function getGlobalSearchDebounce(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getGlobalSearchDebounce();
|
||||
return $this->getCurrentPanelOrDefault()->getGlobalSearchDebounce();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,32 +232,32 @@ class FilamentManager
|
||||
*/
|
||||
public function getGlobalSearchKeyBindings(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getGlobalSearchKeyBindings();
|
||||
return $this->getCurrentPanelOrDefault()->getGlobalSearchKeyBindings();
|
||||
}
|
||||
|
||||
public function getGlobalSearchFieldSuffix(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getGlobalSearchFieldSuffix();
|
||||
return $this->getCurrentPanelOrDefault()->getGlobalSearchFieldSuffix();
|
||||
}
|
||||
|
||||
public function getGlobalSearchProvider(): ?GlobalSearchProvider
|
||||
{
|
||||
return $this->getCurrentPanel()->getGlobalSearchProvider();
|
||||
return $this->getCurrentPanelOrDefault()->getGlobalSearchProvider();
|
||||
}
|
||||
|
||||
public function getHomeUrl(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getHomeUrl() ?? $this->getCurrentPanel()->getUrl();
|
||||
return $this->getCurrentPanelOrDefault()->getHomeUrl() ?? $this->getCurrentPanelOrDefault()->getUrl();
|
||||
}
|
||||
|
||||
public function getId(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()?->getId();
|
||||
return $this->getCurrentPanelOrDefault()?->getId();
|
||||
}
|
||||
|
||||
public function getSubNavigationPosition(): SubNavigationPosition
|
||||
{
|
||||
return $this->getCurrentPanel()?->getSubNavigationPosition();
|
||||
return $this->getCurrentPanelOrDefault()?->getSubNavigationPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,7 +265,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getLoginUrl(array $parameters = []): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getLoginUrl($parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getLoginUrl($parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,17 +273,17 @@ class FilamentManager
|
||||
*/
|
||||
public function getLogoutUrl(array $parameters = []): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getLogoutUrl($parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getLogoutUrl($parameters);
|
||||
}
|
||||
|
||||
public function getMaxContentWidth(): MaxWidth | string | null
|
||||
{
|
||||
return $this->getCurrentPanel()->getMaxContentWidth();
|
||||
return $this->getCurrentPanelOrDefault()->getMaxContentWidth();
|
||||
}
|
||||
|
||||
public function getSimplePageMaxContentWidth(): MaxWidth | string | null
|
||||
{
|
||||
return $this->getCurrentPanel()->getSimplePageMaxContentWidth();
|
||||
return $this->getCurrentPanelOrDefault()->getSimplePageMaxContentWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,7 +291,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getModelResource(string | Model $model): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getModelResource($model);
|
||||
return $this->getCurrentPanelOrDefault()->getModelResource($model);
|
||||
}
|
||||
|
||||
public function getNameForDefaultAvatar(Model | Authenticatable $record): string
|
||||
@@ -300,7 +308,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getNavigation(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getNavigation();
|
||||
return $this->getCurrentPanelOrDefault()->getNavigation();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,7 +316,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getNavigationGroups(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getNavigationGroups();
|
||||
return $this->getCurrentPanelOrDefault()->getNavigationGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,7 +324,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getNavigationItems(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getNavigationItems();
|
||||
return $this->getCurrentPanelOrDefault()->getNavigationItems();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +332,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getClusteredComponents(?string $cluster): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getClusteredComponents($cluster);
|
||||
return $this->getCurrentPanelOrDefault()->getClusteredComponents($cluster);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,10 +340,10 @@ class FilamentManager
|
||||
*/
|
||||
public function getPages(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getPages();
|
||||
return $this->getCurrentPanelOrDefault()->getPages();
|
||||
}
|
||||
|
||||
public function getPanel(?string $id = null, bool $isStrict = true): Panel
|
||||
public function getPanel(?string $id = null, bool $isStrict = true): ?Panel
|
||||
{
|
||||
return app(PanelRegistry::class)->get($id, $isStrict);
|
||||
}
|
||||
@@ -350,7 +358,7 @@ class FilamentManager
|
||||
|
||||
public function getPlugin(string $id): Plugin
|
||||
{
|
||||
return $this->getCurrentPanel()->getPlugin($id);
|
||||
return $this->getCurrentPanelOrDefault()->getPlugin($id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,12 +366,12 @@ class FilamentManager
|
||||
*/
|
||||
public function getProfileUrl(array $parameters = []): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getProfileUrl($parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getProfileUrl($parameters);
|
||||
}
|
||||
|
||||
public function isProfilePageSimple(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->isProfilePageSimple();
|
||||
return $this->getCurrentPanelOrDefault()->isProfilePageSimple();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,7 +379,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getRegistrationUrl(array $parameters = []): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getRegistrationUrl($parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getRegistrationUrl($parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,7 +387,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getRequestPasswordResetUrl(array $parameters = []): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getRequestPasswordResetUrl($parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getRequestPasswordResetUrl($parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,7 +395,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getResetPasswordUrl(string $token, CanResetPassword | Model | Authenticatable $user, array $parameters = []): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getResetPasswordUrl($token, $user, $parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getResetPasswordUrl($token, $user, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,7 +403,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getResources(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getResources();
|
||||
return $this->getCurrentPanelOrDefault()->getResources();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,12 +411,12 @@ class FilamentManager
|
||||
*/
|
||||
public function getResourceUrl(string | Model $model, string $name = 'index', array $parameters = [], bool $isAbsolute = true, ?Model $tenant = null): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getResourceUrl($model, $name, $parameters, $isAbsolute, $tenant);
|
||||
return $this->getCurrentPanelOrDefault()->getResourceUrl($model, $name, $parameters, $isAbsolute, $tenant);
|
||||
}
|
||||
|
||||
public function getSidebarWidth(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getSidebarWidth();
|
||||
return $this->getCurrentPanelOrDefault()->getSidebarWidth();
|
||||
}
|
||||
|
||||
public function getTenant(): ?Model
|
||||
@@ -433,7 +441,7 @@ class FilamentManager
|
||||
|
||||
public function getTenantBillingProvider(): ?Billing\Providers\Contracts\BillingProvider
|
||||
{
|
||||
return $this->getCurrentPanel()->getTenantBillingProvider();
|
||||
return $this->getCurrentPanelOrDefault()->getTenantBillingProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,7 +449,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getTenantBillingUrl(array $parameters = [], ?Model $tenant = null): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getTenantBillingUrl($tenant ?? $this->getTenant(), $parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getTenantBillingUrl($tenant ?? $this->getTenant(), $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,7 +457,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getTenantMenuItems(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getTenantMenuItems();
|
||||
return $this->getCurrentPanelOrDefault()->getTenantMenuItems();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -457,7 +465,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getTenantModel(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getTenantModel();
|
||||
return $this->getCurrentPanelOrDefault()->getTenantModel();
|
||||
}
|
||||
|
||||
public function getTenantName(Model $tenant): string
|
||||
@@ -471,17 +479,17 @@ class FilamentManager
|
||||
|
||||
public function getTenantOwnershipRelationshipName(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getTenantOwnershipRelationshipName();
|
||||
return $this->getCurrentPanelOrDefault()->getTenantOwnershipRelationshipName();
|
||||
}
|
||||
|
||||
public function getProfilePage(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getProfilePage();
|
||||
return $this->getCurrentPanelOrDefault()->getProfilePage();
|
||||
}
|
||||
|
||||
public function getTenantProfilePage(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getTenantProfilePage();
|
||||
return $this->getCurrentPanelOrDefault()->getTenantProfilePage();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -491,12 +499,12 @@ class FilamentManager
|
||||
{
|
||||
$parameters['tenant'] ??= $this->getTenant();
|
||||
|
||||
return $this->getCurrentPanel()->getTenantProfileUrl($parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getTenantProfileUrl($parameters);
|
||||
}
|
||||
|
||||
public function getTenantRegistrationPage(): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getTenantRegistrationPage();
|
||||
return $this->getCurrentPanelOrDefault()->getTenantRegistrationPage();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -504,12 +512,12 @@ class FilamentManager
|
||||
*/
|
||||
public function getTenantRegistrationUrl(array $parameters = []): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getTenantRegistrationUrl($parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getTenantRegistrationUrl($parameters);
|
||||
}
|
||||
|
||||
public function getTheme(): Theme
|
||||
{
|
||||
return $this->getCurrentPanel()->getTheme();
|
||||
return $this->getCurrentPanelOrDefault()->getTheme();
|
||||
}
|
||||
|
||||
public function getUserAvatarUrl(Model | Authenticatable $user): string
|
||||
@@ -530,7 +538,7 @@ class FilamentManager
|
||||
public function getUserDefaultTenant(HasTenants | Model | Authenticatable $user): ?Model
|
||||
{
|
||||
$tenant = null;
|
||||
$panel = $this->getCurrentPanel();
|
||||
$panel = $this->getCurrentPanelOrDefault();
|
||||
|
||||
if ($user instanceof HasDefaultTenant) {
|
||||
$tenant = $user->getDefaultTenant($panel);
|
||||
@@ -548,7 +556,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getUserMenuItems(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getUserMenuItems();
|
||||
return $this->getCurrentPanelOrDefault()->getUserMenuItems();
|
||||
}
|
||||
|
||||
public function getUserName(Model | Authenticatable $user): string
|
||||
@@ -565,7 +573,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getUserTenants(HasTenants | Model | Authenticatable $user): array
|
||||
{
|
||||
$tenants = $user->getTenants($this->getCurrentPanel());
|
||||
$tenants = $user->getTenants($this->getCurrentPanelOrDefault());
|
||||
|
||||
if ($tenants instanceof Collection) {
|
||||
$tenants = $tenants->all();
|
||||
@@ -576,7 +584,7 @@ class FilamentManager
|
||||
|
||||
public function getUrl(?Model $tenant = null): ?string
|
||||
{
|
||||
return $this->getCurrentPanel()->getUrl($tenant);
|
||||
return $this->getCurrentPanelOrDefault()->getUrl($tenant);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -584,7 +592,7 @@ class FilamentManager
|
||||
*/
|
||||
public function getVerifyEmailUrl(MustVerifyEmail | Model | Authenticatable $user, array $parameters = []): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getVerifyEmailUrl($user, $parameters);
|
||||
return $this->getCurrentPanelOrDefault()->getVerifyEmailUrl($user, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,117 +600,117 @@ class FilamentManager
|
||||
*/
|
||||
public function getWidgets(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getWidgets();
|
||||
return $this->getCurrentPanelOrDefault()->getWidgets();
|
||||
}
|
||||
|
||||
public function hasBreadcrumbs(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasBreadcrumbs();
|
||||
return $this->getCurrentPanelOrDefault()->hasBreadcrumbs();
|
||||
}
|
||||
|
||||
public function hasBroadcasting(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasBroadcasting();
|
||||
return $this->getCurrentPanelOrDefault()->hasBroadcasting();
|
||||
}
|
||||
|
||||
public function hasCollapsibleNavigationGroups(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasCollapsibleNavigationGroups();
|
||||
return $this->getCurrentPanelOrDefault()->hasCollapsibleNavigationGroups();
|
||||
}
|
||||
|
||||
public function hasDarkMode(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasDarkMode();
|
||||
return $this->getCurrentPanelOrDefault()->hasDarkMode();
|
||||
}
|
||||
|
||||
public function hasDarkModeForced(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasDarkModeForced();
|
||||
return $this->getCurrentPanelOrDefault()->hasDarkModeForced();
|
||||
}
|
||||
|
||||
public function hasDatabaseNotifications(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasDatabaseNotifications();
|
||||
return $this->getCurrentPanelOrDefault()->hasDatabaseNotifications();
|
||||
}
|
||||
|
||||
public function hasLazyLoadedDatabaseNotifications(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasLazyLoadedDatabaseNotifications();
|
||||
return $this->getCurrentPanelOrDefault()->hasLazyLoadedDatabaseNotifications();
|
||||
}
|
||||
|
||||
public function hasEmailVerification(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasEmailVerification();
|
||||
return $this->getCurrentPanelOrDefault()->hasEmailVerification();
|
||||
}
|
||||
|
||||
public function hasLogin(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasLogin();
|
||||
return $this->getCurrentPanelOrDefault()->hasLogin();
|
||||
}
|
||||
|
||||
public function hasNavigation(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasNavigation();
|
||||
return $this->getCurrentPanelOrDefault()->hasNavigation();
|
||||
}
|
||||
|
||||
public function hasPasswordReset(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasPasswordReset();
|
||||
return $this->getCurrentPanelOrDefault()->hasPasswordReset();
|
||||
}
|
||||
|
||||
public function hasPlugin(string $id): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasPlugin($id);
|
||||
return $this->getCurrentPanelOrDefault()->hasPlugin($id);
|
||||
}
|
||||
|
||||
public function hasProfile(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasProfile();
|
||||
return $this->getCurrentPanelOrDefault()->hasProfile();
|
||||
}
|
||||
|
||||
public function hasRegistration(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasRegistration();
|
||||
return $this->getCurrentPanelOrDefault()->hasRegistration();
|
||||
}
|
||||
|
||||
public function hasTenantMenu(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasTenantMenu();
|
||||
return $this->getCurrentPanelOrDefault()->hasTenantMenu();
|
||||
}
|
||||
|
||||
public function hasTenancy(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasTenancy();
|
||||
return $this->getCurrentPanelOrDefault()->hasTenancy();
|
||||
}
|
||||
|
||||
public function hasTenantBilling(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasTenantBilling();
|
||||
return $this->getCurrentPanelOrDefault()->hasTenantBilling();
|
||||
}
|
||||
|
||||
public function hasTenantProfile(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasTenantProfile();
|
||||
return $this->getCurrentPanelOrDefault()->hasTenantProfile();
|
||||
}
|
||||
|
||||
public function hasTenantRegistration(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasTenantRegistration();
|
||||
return $this->getCurrentPanelOrDefault()->hasTenantRegistration();
|
||||
}
|
||||
|
||||
public function hasTopbar(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasTopbar();
|
||||
return $this->getCurrentPanelOrDefault()->hasTopbar();
|
||||
}
|
||||
|
||||
public function hasTopNavigation(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasTopNavigation();
|
||||
return $this->getCurrentPanelOrDefault()->hasTopNavigation();
|
||||
}
|
||||
|
||||
public function hasUnsavedChangesAlerts(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->hasUnsavedChangesAlerts();
|
||||
return $this->getCurrentPanelOrDefault()->hasUnsavedChangesAlerts();
|
||||
}
|
||||
|
||||
public function isGlobalSearchEnabled(): bool
|
||||
@@ -727,12 +735,12 @@ class FilamentManager
|
||||
|
||||
public function isSidebarCollapsibleOnDesktop(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->isSidebarCollapsibleOnDesktop();
|
||||
return $this->getCurrentPanelOrDefault()->isSidebarCollapsibleOnDesktop();
|
||||
}
|
||||
|
||||
public function isSidebarFullyCollapsibleOnDesktop(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->isSidebarFullyCollapsibleOnDesktop();
|
||||
return $this->getCurrentPanelOrDefault()->isSidebarFullyCollapsibleOnDesktop();
|
||||
}
|
||||
|
||||
public function registerPanel(Panel $panel): void
|
||||
@@ -931,12 +939,12 @@ class FilamentManager
|
||||
|
||||
public function getDefaultThemeMode(): ThemeMode
|
||||
{
|
||||
return $this->getCurrentPanel()->getDefaultThemeMode();
|
||||
return $this->getCurrentPanelOrDefault()->getDefaultThemeMode();
|
||||
}
|
||||
|
||||
public function arePasswordsRevealable(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->arePasswordsRevealable();
|
||||
return $this->getCurrentPanelOrDefault()->arePasswordsRevealable();
|
||||
}
|
||||
|
||||
public function getCurrentDomain(?string $testingDomain = null): string
|
||||
@@ -958,7 +966,7 @@ class FilamentManager
|
||||
|
||||
public function getTenancyScopeName(): string
|
||||
{
|
||||
return $this->getCurrentPanel()->getTenancyScopeName();
|
||||
return $this->getCurrentPanelOrDefault()->getTenancyScopeName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -966,11 +974,11 @@ class FilamentManager
|
||||
*/
|
||||
public function getMultiFactorAuthenticationProviders(): array
|
||||
{
|
||||
return $this->getCurrentPanel()->getMultiFactorAuthenticationProviders();
|
||||
return $this->getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders();
|
||||
}
|
||||
|
||||
public function isAuthorizationStrict(): bool
|
||||
{
|
||||
return $this->getCurrentPanel()->isAuthorizationStrict();
|
||||
return $this->getCurrentPanelOrDefault()->isAuthorizationStrict();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class RedirectToHomeController
|
||||
{
|
||||
public function __invoke(): RedirectResponse
|
||||
{
|
||||
$panel = Filament::getCurrentPanel();
|
||||
$panel = Filament::getCurrentPanelOrDefault();
|
||||
|
||||
$url = $panel->getUrl(Filament::getTenant());
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class RedirectToTenantController
|
||||
{
|
||||
public function __invoke(): RedirectResponse
|
||||
{
|
||||
$panel = Filament::getCurrentPanel();
|
||||
$panel = Filament::getCurrentPanelOrDefault();
|
||||
$tenant = Filament::getUserDefaultTenant(Filament::auth()->user());
|
||||
|
||||
if (! $tenant) {
|
||||
|
||||
@@ -27,7 +27,7 @@ class Authenticate extends Middleware
|
||||
/** @var Model $user */
|
||||
$user = $guard->user();
|
||||
|
||||
$panel = Filament::getCurrentPanel();
|
||||
$panel = Filament::getCurrentPanelOrDefault();
|
||||
|
||||
abort_if(
|
||||
$user instanceof FilamentUser ?
|
||||
|
||||
@@ -12,7 +12,7 @@ class IdentifyTenant
|
||||
{
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
$panel = Filament::getCurrentPanel();
|
||||
$panel = Filament::getCurrentPanelOrDefault();
|
||||
|
||||
if (! $panel->hasTenancy()) {
|
||||
return $next($request);
|
||||
|
||||
@@ -25,7 +25,7 @@ class NavigationManager
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->panel = Filament::getCurrentPanel();
|
||||
$this->panel = Filament::getCurrentPanelOrDefault();
|
||||
|
||||
$this->navigationGroups = array_map(
|
||||
fn (NavigationGroup | string $group): NavigationGroup | string => $group instanceof NavigationGroup ? (clone $group) : $group,
|
||||
|
||||
@@ -125,7 +125,7 @@ class EditProfile extends Page
|
||||
|
||||
public static function getRouteName(?string $panel = null): string
|
||||
{
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanel();
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanelOrDefault();
|
||||
|
||||
return $panel->generateRouteName('auth.' . static::getRelativeRouteName());
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ class Login extends SimplePage
|
||||
|
||||
if (
|
||||
($user instanceof FilamentUser) &&
|
||||
(! $user->canAccessPanel(Filament::getCurrentPanel()))
|
||||
(! $user->canAccessPanel(Filament::getCurrentPanelOrDefault()))
|
||||
) {
|
||||
Filament::auth()->logout();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ trait CanUseDatabaseTransactions
|
||||
|
||||
public function hasDatabaseTransactions(): bool
|
||||
{
|
||||
return $this->hasDatabaseTransactions ?? Filament::getCurrentPanel()->hasDatabaseTransactions();
|
||||
return $this->hasDatabaseTransactions ?? Filament::getCurrentPanelOrDefault()->hasDatabaseTransactions();
|
||||
}
|
||||
|
||||
protected function beginDatabaseTransaction(): void
|
||||
|
||||
@@ -99,7 +99,7 @@ abstract class Page extends BasePage
|
||||
return;
|
||||
}
|
||||
|
||||
Filament::getCurrentPanel()
|
||||
Filament::getCurrentPanelOrDefault()
|
||||
->navigationItems(static::getNavigationItems());
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ abstract class Page extends BasePage
|
||||
|
||||
public static function getRouteName(?string $panel = null): string
|
||||
{
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanel();
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanelOrDefault();
|
||||
|
||||
$routeName = 'pages.' . static::getRelativeRouteName();
|
||||
$routeName = static::prependClusterRouteBaseName($routeName);
|
||||
|
||||
@@ -55,7 +55,7 @@ abstract class EditTenantProfile extends Page
|
||||
|
||||
public static function getRouteName(?string $panel = null): string
|
||||
{
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanel();
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanelOrDefault();
|
||||
|
||||
return $panel->generateRouteName('tenant.' . static::getRelativeRouteName());
|
||||
}
|
||||
|
||||
@@ -12,24 +12,13 @@ class PanelRegistry
|
||||
*/
|
||||
public array $panels = [];
|
||||
|
||||
public ?Panel $defaultPanel = null;
|
||||
|
||||
public function register(Panel $panel): void
|
||||
{
|
||||
$this->panels[$panel->getId()] = $panel;
|
||||
|
||||
$panel->register();
|
||||
|
||||
if (! $panel->isDefault()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (app()->resolved('filament')) {
|
||||
app('filament')->setCurrentPanel($panel);
|
||||
}
|
||||
|
||||
app()->resolving(
|
||||
'filament',
|
||||
fn (FilamentManager $manager) => $manager->setCurrentPanel($panel),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,22 +26,14 @@ class PanelRegistry
|
||||
*/
|
||||
public function getDefault(): Panel
|
||||
{
|
||||
return Arr::first(
|
||||
return $this->defaultPanel ??= Arr::first(
|
||||
$this->panels,
|
||||
fn (Panel $panel): bool => $panel->isDefault(),
|
||||
fn () => throw NoDefaultPanelSetException::make(),
|
||||
fn () => new NoDefaultPanelSetException('No default Filament panel is set. You may do this with the `default()` method inside a Filament provider\'s `panel()` configuration.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NoDefaultPanelSetException
|
||||
*/
|
||||
public function get(?string $id = null, bool $isStrict = true): Panel
|
||||
{
|
||||
return $this->find($id, $isStrict) ?? $this->getDefault();
|
||||
}
|
||||
|
||||
protected function find(?string $id = null, bool $isStrict = true): ?Panel
|
||||
public function get(?string $id = null, bool $isStrict = true): ?Panel
|
||||
{
|
||||
if ($id === null) {
|
||||
return null;
|
||||
|
||||
@@ -216,7 +216,7 @@ class RelationManager extends Component implements Actions\Contracts\HasActions,
|
||||
return false;
|
||||
}
|
||||
|
||||
$panel = Filament::getCurrentPanel();
|
||||
$panel = Filament::getCurrentPanelOrDefault();
|
||||
|
||||
if (! $panel) {
|
||||
return false;
|
||||
|
||||
@@ -115,7 +115,7 @@ trait BelongsToTenant
|
||||
}
|
||||
|
||||
$model::addGlobalScope($panel->getTenancyScopeName(), function (Builder $query) use ($panel) {
|
||||
if (Filament::getCurrentPanel() !== $panel) {
|
||||
if (Filament::getCurrentPanelOrDefault() !== $panel) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ trait BelongsToTenant
|
||||
}
|
||||
|
||||
$model::creating(function (Model $record) use ($panel) {
|
||||
if (Filament::getCurrentPanel() !== $panel) {
|
||||
if (Filament::getCurrentPanelOrDefault() !== $panel) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ trait BelongsToTenant
|
||||
});
|
||||
|
||||
$model::created(function (Model $record) use ($panel) {
|
||||
if (Filament::getCurrentPanel() !== $panel) {
|
||||
if (Filament::getCurrentPanelOrDefault() !== $panel) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ trait HasNavigation
|
||||
return;
|
||||
}
|
||||
|
||||
Filament::getCurrentPanel()
|
||||
Filament::getCurrentPanelOrDefault()
|
||||
->navigationItems(static::getNavigationItems());
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ trait HasRoutes
|
||||
return $parentResource->getParentResource()::getRouteBaseName($panel) . '.' . $parentResource->getRouteName();
|
||||
}
|
||||
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanel();
|
||||
$panel = $panel ? Filament::getPanel($panel) : Filament::getCurrentPanelOrDefault();
|
||||
|
||||
$routeBaseName = (string) str(static::getSlug())
|
||||
->replace('/', '.')
|
||||
|
||||
+7
-7
@@ -21,7 +21,7 @@ beforeEach(function () {
|
||||
});
|
||||
|
||||
it('can render the challenge form after valid login credentials are successfully used', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasEmailCodeAuthentication()
|
||||
@@ -52,7 +52,7 @@ it('can render the challenge form after valid login credentials are successfully
|
||||
});
|
||||
|
||||
it('will authenticate the user after a valid challenge code is used', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasEmailCodeAuthentication()
|
||||
@@ -79,7 +79,7 @@ it('will authenticate the user after a valid challenge code is used', function (
|
||||
});
|
||||
|
||||
it('can resend the code to the user', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasEmailCodeAuthentication()
|
||||
@@ -140,7 +140,7 @@ it('will not render the challenge form if a user does not have multi-factor auth
|
||||
});
|
||||
|
||||
it('will not authenticate the user when an invalid challenge code is used', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasEmailCodeAuthentication()
|
||||
@@ -171,7 +171,7 @@ it('will not authenticate the user when an invalid challenge code is used', func
|
||||
});
|
||||
|
||||
test('challenge codes are required', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasEmailCodeAuthentication()
|
||||
@@ -200,7 +200,7 @@ test('challenge codes are required', function () {
|
||||
});
|
||||
|
||||
test('challenge codes must be numeric', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasEmailCodeAuthentication()
|
||||
@@ -229,7 +229,7 @@ test('challenge codes must be numeric', function () {
|
||||
});
|
||||
|
||||
test('challenge codes must be 6 digits', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasEmailCodeAuthentication()
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ beforeEach(function () {
|
||||
});
|
||||
|
||||
it('can remove authentication when valid challenge code is used', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -76,7 +76,7 @@ it('can resend the code to the user', function () {
|
||||
});
|
||||
|
||||
it('will not remove authentication when an invalid code is used', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -128,7 +128,7 @@ test('codes are required', function () {
|
||||
});
|
||||
|
||||
test('codes must be 6 digits', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
|
||||
+4
-4
@@ -24,7 +24,7 @@ beforeEach(function () {
|
||||
});
|
||||
|
||||
it('can generate a secret when the action is mounted', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$livewire = livewire(EditProfile::class)
|
||||
->mountAction(TestAction::make('setUpEmailCodeAuthentication')
|
||||
@@ -58,7 +58,7 @@ it('can generate a secret when the action is mounted', function () {
|
||||
});
|
||||
|
||||
it('can save the secret to the user when the action is submitted', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -102,7 +102,7 @@ it('can resend the code to the user', function () {
|
||||
});
|
||||
|
||||
it('will not set up authentication when an invalid code is used', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -159,7 +159,7 @@ test('codes are required', function () {
|
||||
});
|
||||
|
||||
test('codes must be 6 digits', function () {
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$emailCodeAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ beforeEach(function () {
|
||||
});
|
||||
|
||||
it('can generate new recovery codes when valid challenge code is used', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -114,7 +114,7 @@ it('can generate new recovery codes when the current user\'s password is used',
|
||||
});
|
||||
|
||||
it('will not generate new recovery codes when an invalid code is used', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -162,7 +162,7 @@ test('codes are required without the user\'s current password', function () {
|
||||
});
|
||||
|
||||
test('codes must be 6 digits', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
|
||||
+5
-5
@@ -16,7 +16,7 @@ uses(TestCase::class);
|
||||
beforeEach(function () {
|
||||
Filament::setCurrentPanel('google-two-factor-authentication');
|
||||
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$this->recoveryCodes = $googleTwoFactorAuthentication->generateRecoveryCodes();
|
||||
|
||||
@@ -26,7 +26,7 @@ beforeEach(function () {
|
||||
});
|
||||
|
||||
it('can remove authentication when valid challenge code is used', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -95,7 +95,7 @@ it('can remove authentication when a valid recovery code is used', function () {
|
||||
});
|
||||
|
||||
it('will not remove authentication when an invalid code is used', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -163,7 +163,7 @@ test('codes are required without a recovery code', function () {
|
||||
});
|
||||
|
||||
test('codes must be 6 digits', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -234,7 +234,7 @@ it('will not remove authentication when an invalid recovery code is used', funct
|
||||
});
|
||||
|
||||
it('will not remove authentication with a recovery code if recovery is disabled', function () {
|
||||
Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders())
|
||||
Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders())
|
||||
->recoverable(false);
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ it('can generate a secret and recovery codes when the action is mounted', functi
|
||||
});
|
||||
|
||||
it('can save the secret and recovery codes to the user when the action is submitted', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -104,7 +104,7 @@ it('can save the secret and recovery codes to the user when the action is submit
|
||||
});
|
||||
|
||||
it('will not set up authentication when an invalid code is used', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -177,7 +177,7 @@ test('codes are required', function () {
|
||||
});
|
||||
|
||||
test('codes must be 6 digits', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$user = auth()->user();
|
||||
|
||||
|
||||
+9
-9
@@ -39,7 +39,7 @@ it('can render the challenge form after valid login credentials are successfully
|
||||
});
|
||||
|
||||
it('will authenticate the user after a valid challenge code is used', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasGoogleTwoFactorAuthentication()
|
||||
@@ -66,7 +66,7 @@ it('will authenticate the user after a valid challenge code is used', function (
|
||||
});
|
||||
|
||||
it('will make the recovery code field visible when the user requests it', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasGoogleTwoFactorAuthentication()
|
||||
@@ -95,7 +95,7 @@ it('will make the recovery code field visible when the user requests it', functi
|
||||
});
|
||||
|
||||
it('will authenticate the user after a valid recovery code is used', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasGoogleTwoFactorAuthentication($recoveryCodes = $googleTwoFactorAuthentication->generateRecoveryCodes())
|
||||
@@ -158,7 +158,7 @@ it('will not render the challenge form if a user does not have multi-factor auth
|
||||
});
|
||||
|
||||
it('will not authenticate the user when an invalid challenge code is used', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasGoogleTwoFactorAuthentication()
|
||||
@@ -189,7 +189,7 @@ it('will not authenticate the user when an invalid challenge code is used', func
|
||||
});
|
||||
|
||||
test('challenge codes are required', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasGoogleTwoFactorAuthentication()
|
||||
@@ -218,7 +218,7 @@ test('challenge codes are required', function () {
|
||||
});
|
||||
|
||||
test('challenge codes must be numeric', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasGoogleTwoFactorAuthentication()
|
||||
@@ -247,7 +247,7 @@ test('challenge codes must be numeric', function () {
|
||||
});
|
||||
|
||||
test('challenge codes must be 6 digits', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasGoogleTwoFactorAuthentication()
|
||||
@@ -276,7 +276,7 @@ test('challenge codes must be 6 digits', function () {
|
||||
});
|
||||
|
||||
it('will not authenticate the user when an invalid recovery code is used', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders());
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders());
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
->hasGoogleTwoFactorAuthentication()
|
||||
@@ -317,7 +317,7 @@ it('will not authenticate the user when an invalid recovery code is used', funct
|
||||
});
|
||||
|
||||
it('will not authenticate the user with a valid recovery code if recovery is disabled', function () {
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanel()->getMultiFactorAuthenticationProviders())
|
||||
$googleTwoFactorAuthentication = Arr::first(Filament::getCurrentPanelOrDefault()->getMultiFactorAuthenticationProviders())
|
||||
->recoverable(false);
|
||||
|
||||
$userToAuthenticate = User::factory()
|
||||
|
||||
@@ -36,7 +36,7 @@ it('can register', function () {
|
||||
|
||||
$this->assertGuest();
|
||||
|
||||
Filament::getCurrentPanel()->requiresEmailVerification(false);
|
||||
Filament::getCurrentPanelOrDefault()->requiresEmailVerification(false);
|
||||
|
||||
$userToRegister = User::factory()->make();
|
||||
|
||||
@@ -67,7 +67,7 @@ it('can register and redirect user to their intended URL', function () {
|
||||
|
||||
session()->put('url.intended', $intendedUrl = Str::random());
|
||||
|
||||
Filament::getCurrentPanel()->requiresEmailVerification(false);
|
||||
Filament::getCurrentPanelOrDefault()->requiresEmailVerification(false);
|
||||
|
||||
$userToRegister = User::factory()->make();
|
||||
|
||||
|
||||
@@ -143,8 +143,8 @@ it('can generate a page class in a resource', function () {
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
@@ -175,8 +175,8 @@ it('can generate a page view in a resource', function () {
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
@@ -207,8 +207,8 @@ it('can generate a create page class in a resource', function () {
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
@@ -241,8 +241,8 @@ it('can generate an edit page class in a resource', function () {
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
@@ -275,8 +275,8 @@ it('can generate a view page class in a resource', function () {
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
@@ -325,8 +325,8 @@ $runGenerateManageRelatedRecordsPageCommand = function (TestCase $testCase): Pen
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\TeamResource',
|
||||
'App\\Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
@@ -45,8 +45,8 @@ beforeEach(function () {
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/UserResource/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\TeamResource',
|
||||
'App\\Filament\\Resources\\UserResource',
|
||||
];
|
||||
|
||||
@@ -134,8 +134,8 @@ it('can generate a page class in a resource', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -166,8 +166,8 @@ it('can generate a page view in a resource', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -198,8 +198,8 @@ it('can generate a create page class in a resource', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -232,8 +232,8 @@ it('can generate an edit page class in a resource', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -266,8 +266,8 @@ it('can generate a view page class in a resource', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -316,8 +316,8 @@ $runGenerateManageRelatedRecordsPageCommand = function (TestCase $testCase): Pen
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Teams\\TeamResource',
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -40,8 +40,8 @@ beforeEach(function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Teams\\TeamResource',
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -444,8 +444,8 @@ it('can generate a nested resource class', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -474,8 +474,8 @@ it('can generate a nested resource class with a plural parent resource name', fu
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -504,8 +504,8 @@ it('can generate a nested resource class with a parent resource name with `Resou
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -534,8 +534,8 @@ it('can generate a nested resource form', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -564,8 +564,8 @@ it('can generate a nested resource infolist', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -595,8 +595,8 @@ it('can generate a nested resource create page', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -625,8 +625,8 @@ it('can generate a nested resource edit page', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -655,8 +655,8 @@ it('can generate a nested resource view page', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
@@ -686,8 +686,8 @@ it('can generate a nested resource class in a nested directory', function () {
|
||||
require_once app_path('Filament/Resources/Users/Pages/CreateUser.php');
|
||||
require_once app_path('Filament/Resources/Users/Pages/EditUser.php');
|
||||
|
||||
invade(Filament::getCurrentPanel())->resources = [
|
||||
...invade(Filament::getCurrentPanel())->resources,
|
||||
invade(Filament::getCurrentPanelOrDefault())->resources = [
|
||||
...invade(Filament::getCurrentPanelOrDefault())->resources,
|
||||
'App\\Filament\\Resources\\Users\\UserResource',
|
||||
];
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ it('can retrieve limited search results', function () {
|
||||
});
|
||||
|
||||
it('can retrieve results via custom search provider', function () {
|
||||
Filament::getCurrentPanel()->globalSearch(CustomSearchProvider::class);
|
||||
Filament::getCurrentPanelOrDefault()->globalSearch(CustomSearchProvider::class);
|
||||
|
||||
livewire(GlobalSearch::class)
|
||||
->set('search', 'foo')
|
||||
|
||||
@@ -15,7 +15,7 @@ use Filament\Tests\Panels\Navigation\TestCase;
|
||||
uses(TestCase::class);
|
||||
|
||||
it('can register navigation', function () {
|
||||
Filament::getCurrentPanel()->navigation(function (NavigationBuilder $navigation): NavigationBuilder {
|
||||
Filament::getCurrentPanelOrDefault()->navigation(function (NavigationBuilder $navigation): NavigationBuilder {
|
||||
return $navigation
|
||||
->items([
|
||||
...Dashboard::getNavigationItems(),
|
||||
@@ -80,7 +80,7 @@ it('can register navigation', function () {
|
||||
});
|
||||
|
||||
it('can register navigation groups individually', function () {
|
||||
Filament::getCurrentPanel()->navigation(function (NavigationBuilder $navigation): NavigationBuilder {
|
||||
Filament::getCurrentPanelOrDefault()->navigation(function (NavigationBuilder $navigation): NavigationBuilder {
|
||||
return $navigation
|
||||
->group('Blog', [
|
||||
...PostResource::getNavigationItems(),
|
||||
|
||||
@@ -64,7 +64,7 @@ it('can register navigation items from resources and pages', function () {
|
||||
});
|
||||
|
||||
it('can reorder navigation groups by registering them', function () {
|
||||
Filament::getCurrentPanel()->navigationGroups([
|
||||
Filament::getCurrentPanelOrDefault()->navigationGroups([
|
||||
NavigationGroup::make()->label('Shop'),
|
||||
NavigationGroup::make()->label('Blog'),
|
||||
]);
|
||||
@@ -84,7 +84,7 @@ it('can reorder navigation groups by registering them', function () {
|
||||
});
|
||||
|
||||
it('can reorder navigation groups by registering them with different labels', function () {
|
||||
Filament::getCurrentPanel()->navigationGroups([
|
||||
Filament::getCurrentPanelOrDefault()->navigationGroups([
|
||||
'Shop' => NavigationGroup::make()->label('Store'),
|
||||
'Blog' => NavigationGroup::make()->label('Posts'),
|
||||
]);
|
||||
@@ -104,7 +104,7 @@ it('can reorder navigation groups by registering them with different labels', fu
|
||||
});
|
||||
|
||||
it('can reorder navigation groups by registering their labels', function () {
|
||||
Filament::getCurrentPanel()->navigationGroups([
|
||||
Filament::getCurrentPanelOrDefault()->navigationGroups([
|
||||
'Shop',
|
||||
'Blog',
|
||||
]);
|
||||
|
||||
@@ -175,12 +175,12 @@ it('can render page if the policy viewAny returns an allowed response', function
|
||||
});
|
||||
|
||||
it('does not render page without a policy if authorization is strict', function () {
|
||||
Filament::getCurrentPanel()->strictAuthorization();
|
||||
Filament::getCurrentPanelOrDefault()->strictAuthorization();
|
||||
|
||||
$this->get(TicketMessageResource::getUrl('create'))
|
||||
->assertServerError();
|
||||
|
||||
Filament::getCurrentPanel()->strictAuthorization(false);
|
||||
Filament::getCurrentPanelOrDefault()->strictAuthorization(false);
|
||||
});
|
||||
|
||||
it('does not render page if the policy viewAny returns false', function () {
|
||||
|
||||
@@ -154,7 +154,7 @@ it('can render page if the policy viewAny returns an allowed response', function
|
||||
});
|
||||
|
||||
it('does not render page without a policy if authorization is strict', function () {
|
||||
Filament::getCurrentPanel()->strictAuthorization();
|
||||
Filament::getCurrentPanelOrDefault()->strictAuthorization();
|
||||
|
||||
$message = TicketMessage::factory()
|
||||
->create();
|
||||
@@ -162,7 +162,7 @@ it('does not render page without a policy if authorization is strict', function
|
||||
$this->get(TicketMessageResource::getUrl('edit', ['record' => $message]))
|
||||
->assertServerError();
|
||||
|
||||
Filament::getCurrentPanel()->strictAuthorization(false);
|
||||
Filament::getCurrentPanelOrDefault()->strictAuthorization(false);
|
||||
});
|
||||
|
||||
it('does not render page if the policy viewAny returns false', function () {
|
||||
|
||||
@@ -164,7 +164,7 @@ it('can render tickets page if the policy viewAny returns an allowed response',
|
||||
});
|
||||
|
||||
it('does not render ticket messages page without a policy if authorization is strict', function () {
|
||||
Filament::getCurrentPanel()->strictAuthorization();
|
||||
Filament::getCurrentPanelOrDefault()->strictAuthorization();
|
||||
|
||||
TicketMessage::factory(10)
|
||||
->create();
|
||||
@@ -172,7 +172,7 @@ it('does not render ticket messages page without a policy if authorization is st
|
||||
$this->get(TicketMessageResource::getUrl('index'))
|
||||
->assertServerError();
|
||||
|
||||
Filament::getCurrentPanel()->strictAuthorization(false);
|
||||
Filament::getCurrentPanelOrDefault()->strictAuthorization(false);
|
||||
});
|
||||
|
||||
it('does not render tickets page if the policy viewAny returns false', function () {
|
||||
|
||||
@@ -104,7 +104,7 @@ it('can render tickets page if the policy viewAny returns an allowed response',
|
||||
});
|
||||
|
||||
it('does not render ticket messages page without a policy if authorization is strict', function () {
|
||||
Filament::getCurrentPanel()->strictAuthorization();
|
||||
Filament::getCurrentPanelOrDefault()->strictAuthorization();
|
||||
|
||||
$message = TicketMessage::factory()
|
||||
->create();
|
||||
@@ -112,7 +112,7 @@ it('does not render ticket messages page without a policy if authorization is st
|
||||
$this->get(TicketMessageResource::getUrl('view', ['record' => $message]))
|
||||
->assertServerError();
|
||||
|
||||
Filament::getCurrentPanel()->strictAuthorization(false);
|
||||
Filament::getCurrentPanelOrDefault()->strictAuthorization(false);
|
||||
});
|
||||
|
||||
it('does not render tickets page if the policy viewAny returns false', function () {
|
||||
|
||||
Reference in New Issue
Block a user