Moved slug panel config to dedicated methods

This commit is contained in:
Boris Glumpler
2024-01-10 21:57:56 +05:45
parent 0a67ffd711
commit 37bdfee84c
4 changed files with 82 additions and 35 deletions
+10 -14
View File
@@ -212,7 +212,7 @@ public function panel(Panel $panel): Panel
## Changing the default slugs
Filament uses sensible English slugs by default when registering its routes. These can be changed by setting them in their respective config methods.
Filament uses sensible English slugs by default when registering its routes. These can be changed by setting them in the methods below.
```php
use Filament\Panel;
@@ -221,18 +221,14 @@ public function panel(Panel $panel): Panel
{
return $panel
// ...
->tenantBillingProvider(slug: 'abrechnung')
->login(slug: 'einloggen')
->passwordReset(
requestSlug: 'anfragen',
resetSlug: 'zuruecksetzen',
prefix: 'passwort-ruecksetzung'
)
->registration(slug: 'registrieren')
->emailVerification(
promptSlug: 'auffordern',
verifySlug: 'verifizieren',
prefix: 'email-verifizierung'
);
->tenantBillingSlug('abrechnung')
->loginSlug('einloggen')
->passwordResetRequestSlug('anfragen')
->passwordResetSlug('zuruecksetzen')
->passwordResetPrefix('passwort-ruecksetzung')
->registrationSlug('registrieren')
->emailVerificationPromptSlug('auffordern')
->emailVerificationVerifySlug('verifizieren')
->emailVerificationPrefix('email-verifizierung');
}
```
+53 -8
View File
@@ -73,13 +73,30 @@ trait HasAuth
/**
* @param string | Closure | array<class-string, string> | null $promptAction
*/
public function emailVerification(string | Closure | array | null $promptAction = EmailVerificationPrompt::class, bool $isRequired = true, string $promptSlug = 'prompt', string $verifySlug = 'verify', string $prefix = 'email-verification'): static
public function emailVerification(string | Closure | array | null $promptAction = EmailVerificationPrompt::class, bool $isRequired = true): static
{
$this->emailVerificationRouteAction = $promptAction;
$this->requiresEmailVerification($isRequired);
$this->emailVerificationPromptRouteSlug = $promptSlug;
$this->emailVerificationVerifyRouteSlug = $verifySlug;
return $this;
}
public function emailVerificationPromptSlug(string $slug): static
{
$this->emailVerificationPromptRouteSlug = $slug;
return $this;
}
public function emailVerificationVerifySlug(string $slug): static
{
$this->emailVerificationVerifyRouteSlug = $slug;
return $this;
}
public function emailVerificationPrefix(string $prefix): static
{
$this->emailVerificationRoutePrefix = $prefix;
return $this;
@@ -102,9 +119,15 @@ trait HasAuth
/**
* @param string | Closure | array<class-string, string> | null $action
*/
public function login(string | Closure | array | null $action = Login::class, string $slug = 'login'): static
public function login(string | Closure | array | null $action = Login::class): static
{
$this->loginRouteAction = $action;
return $this;
}
public function loginSlug(string $slug): static
{
$this->loginRouteSlug = $slug;
return $this;
@@ -114,14 +137,30 @@ trait HasAuth
* @param string | Closure | array<class-string, string> | null $requestAction
* @param string | Closure | array<class-string, string> | null $resetAction
*/
public function passwordReset(string | Closure | array | null $requestAction = RequestPasswordReset::class, string | Closure | array | null $resetAction = ResetPassword::class, string $requestSlug = 'request', string $resetSlug = 'reset', string $prefix = 'password-reset'): static
public function passwordReset(string | Closure | array | null $requestAction = RequestPasswordReset::class, string | Closure | array | null $resetAction = ResetPassword::class): static
{
$this->requestPasswordResetRouteAction = $requestAction;
$this->resetPasswordRouteAction = $resetAction;
$this->requestPasswordResetRouteSlug = $requestSlug;
$this->resetPasswordRouteSlug = $resetSlug;
return $this;
}
public function passwordResetRequestSlug(string $slug): static
{
$this->requestPasswordResetRouteSlug = $slug;
return $this;
}
public function passwordResetSlug(string $slug): static
{
$this->resetPasswordRouteSlug = $slug;
return $this;
}
public function passwordResetPrefix(string $prefix): static
{
$this->resetPasswordRoutePrefix = $prefix;
return $this;
@@ -130,9 +169,15 @@ trait HasAuth
/**
* @param string | Closure | array<class-string, string> | null $action
*/
public function registration(string | Closure | array | null $action = Register::class, string $slug = 'register'): static
public function registration(string | Closure | array | null $action = Register::class): static
{
$this->registrationRouteAction = $action;
return $this;
}
public function registrationSlug(string $slug): static
{
$this->registrationRouteSlug = $slug;
return $this;
@@ -79,9 +79,15 @@ trait HasTenancy
return $this;
}
public function tenantBillingProvider(?BillingProvider $provider, string $slug = 'billing'): static
public function tenantBillingProvider(?BillingProvider $provider): static
{
$this->tenantBillingProvider = $provider;
return $this;
}
public function tenantBillingSlug(string $slug): static
{
$this->tenantBillingRouteSlug = $slug;
return $this;
+12 -12
View File
@@ -22,18 +22,18 @@ class SlugsPanelProvider extends PanelProvider
return $panel
->id('slugs')
->path('slugs')
->login(slug: 'login-test')
->passwordReset(
requestSlug: 'request-test',
resetSlug: 'reset-test',
prefix: 'password-reset-test'
)
->registration(slug: 'register-test')
->emailVerification(
promptSlug: 'prompt-test',
verifySlug: 'verify-test',
prefix: 'email-verification-test'
)
->login()
->loginSlug('login-test')
->passwordReset()
->passwordResetRequestSlug('request-test')
->passwordResetSlug('reset-test')
->passwordResetPrefix('password-reset-test')
->registration()
->registrationSlug('register-test')
->emailVerification()
->emailVerificationPromptSlug('prompt-test')
->emailVerificationVerifySlug('verify-test')
->emailVerificationPrefix('email-verification-test')
->resources([])
->pages([])
->middleware([