From 19d65ad79d76040dd35642bb12f4800ebff52d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Azad=20Furkan=20=C5=9EAKAR?= Date: Tue, 3 Sep 2024 22:18:54 +0300 Subject: [PATCH] Update for Customized Login Page --- .phpunit.cache/test-results | 2 +- README.md | 34 ++++++++++++++++++++++++++++++++++ src/FilamentOtpLoginPlugin.php | 11 ++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results index 1d3081f..919ca6b 100644 --- a/.phpunit.cache/test-results +++ b/.phpunit.cache/test-results @@ -1 +1 @@ -{"version":"pest_2.35.0","defects":[],"times":{"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.354,"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.004}} \ No newline at end of file +{"version":"pest_2.35.0","defects":[],"times":{"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.063,"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.005}} \ No newline at end of file diff --git a/README.md b/README.md index 78051ec..672f9da 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,40 @@ class User extends Authenticatable implements CanLoginDirectly _*Note:* For medium and large scale applications, you only need to run "php artisan model:prune" command as cron to prevent the otp_code table from bloating and performance issues._ +## Custom Login Page + +If you want to customize the login page, you can extend the `\Afsakar\FilamentOtpLogin\Filament\Pages\Login` page and set your custom login page to plugin in the panel provider file with `loginPage` method. + +```php +plugins([ + FilamentOtpLoginPlugin::make() + ->loginPage(OverrideLogin::class), + ]); + } +``` + ## Testing ```bash diff --git a/src/FilamentOtpLoginPlugin.php b/src/FilamentOtpLoginPlugin.php index 7cf91a2..eafd2bf 100644 --- a/src/FilamentOtpLoginPlugin.php +++ b/src/FilamentOtpLoginPlugin.php @@ -8,6 +8,8 @@ class FilamentOtpLoginPlugin implements Plugin { + public string $login = Login::class; + public function getId(): string { return 'filament-otp-login'; @@ -15,7 +17,7 @@ public function getId(): string public function register(Panel $panel): void { - $panel->login(Login::class); + $panel->login($this->login); } public function boot(Panel $panel): void @@ -35,4 +37,11 @@ public static function get(): static return $plugin; } + + public function loginPage(string $login): static + { + $this->login = $login; + + return $this; + } }