From 1f991dbb66b97a08137cb0ad50265e10222d1c5b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 11:38:24 +0000 Subject: [PATCH 01/12] Adds L11 support --- .github/workflows/tests.yml | 6 +++++- composer.json | 12 ++++++------ tests/AuthBackend/ThrottleLoginsTest.php | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 95a91db..924163e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,10 +17,14 @@ jobs: fail-fast: true matrix: php: ['8.0', 8.1, 8.2, 8.3] - laravel: [9, 10] + laravel: [9, 10, 11] exclude: - php: '8.0' laravel: 10 + - php: '8.0' + laravel: 11 + - php: '8.1' + laravel: 11 - php: 8.3 laravel: 9 diff --git a/composer.json b/composer.json index 55db8e1..928acc8 100644 --- a/composer.json +++ b/composer.json @@ -11,14 +11,14 @@ ], "require": { "php": "^8.0", - "illuminate/console": "^9.21|^10.0", - "illuminate/filesystem": "^9.21|^10.0", - "illuminate/support": "^9.21|^10.0", - "illuminate/validation": "^9.21|^10.0" + "illuminate/console": "^9.21|^10.0|^11.0", + "illuminate/filesystem": "^9.21|^10.0|^11.0", + "illuminate/support": "^9.21|^10.0|^11.0", + "illuminate/validation": "^9.21|^10.0|^11.0" }, "require-dev": { - "orchestra/testbench": "^7.0|^8.0", - "phpunit/phpunit": "^9.3" + "orchestra/testbench": "^7.0|^8.0|^9.0", + "phpunit/phpunit": "^9.3|^10.4" }, "autoload": { "psr-4": { diff --git a/tests/AuthBackend/ThrottleLoginsTest.php b/tests/AuthBackend/ThrottleLoginsTest.php index 026dc89..b2c2c3d 100644 --- a/tests/AuthBackend/ThrottleLoginsTest.php +++ b/tests/AuthBackend/ThrottleLoginsTest.php @@ -28,7 +28,7 @@ public function it_can_generate_throttle_key(string $email, string $expectedEmai $this->assertSame($expectedEmail . '|192.168.0.1', $method->invoke($throttle, $request)); } - public function emailProvider(): array + public static function emailProvider(): array { return [ 'lowercase special characters' => ['ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ', 'test@laravel.com'], From 6445537580da473a4ba7267e2db14fd7fe08f73b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 11:39:06 +0000 Subject: [PATCH 02/12] Fixes missing readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ccf8fe..ed28d3d 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Only the latest major version of Laravel UI receives bug fixes. The table below | [1.x](https://github.com/laravel/ui/tree/1.x) | 5.8, 6.x | | [2.x](https://github.com/laravel/ui/tree/2.x) | 7.x | | [3.x](https://github.com/laravel/ui/tree/3.x) | 8.x | -| [4.x](https://github.com/laravel/ui/tree/4.x) | 9.x, 10.x | +| [4.x](https://github.com/laravel/ui/tree/4.x) | 9.x, 10.x, 11.x | ### Installation From 327c798c68f3684cd2b005f72fc833890d450905 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 11:45:07 +0000 Subject: [PATCH 03/12] Removes references to `RouteServiceProvider` --- stubs/Auth/ConfirmPasswordController.stub | 3 +-- stubs/Auth/LoginController.stub | 3 +-- stubs/Auth/RegisterController.stub | 3 +-- stubs/Auth/ResetPasswordController.stub | 3 +-- stubs/Auth/VerificationController.stub | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/stubs/Auth/ConfirmPasswordController.stub b/stubs/Auth/ConfirmPasswordController.stub index 138c1f0..3559954 100644 --- a/stubs/Auth/ConfirmPasswordController.stub +++ b/stubs/Auth/ConfirmPasswordController.stub @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\ConfirmsPasswords; class ConfirmPasswordController extends Controller @@ -26,7 +25,7 @@ class ConfirmPasswordController extends Controller * * @var string */ - protected $redirectTo = RouteServiceProvider::HOME; + protected $redirectTo = '/home'; /** * Create a new controller instance. diff --git a/stubs/Auth/LoginController.stub b/stubs/Auth/LoginController.stub index 18a0d08..b2ea669 100644 --- a/stubs/Auth/LoginController.stub +++ b/stubs/Auth/LoginController.stub @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\AuthenticatesUsers; class LoginController extends Controller @@ -26,7 +25,7 @@ class LoginController extends Controller * * @var string */ - protected $redirectTo = RouteServiceProvider::HOME; + protected $redirectTo = '/home'; /** * Create a new controller instance. diff --git a/stubs/Auth/RegisterController.stub b/stubs/Auth/RegisterController.stub index ed1a5e0..961ea36 100644 --- a/stubs/Auth/RegisterController.stub +++ b/stubs/Auth/RegisterController.stub @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; use App\Models\User; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Support\Facades\Hash; @@ -29,7 +28,7 @@ class RegisterController extends Controller * * @var string */ - protected $redirectTo = RouteServiceProvider::HOME; + protected $redirectTo = '/home'; /** * Create a new controller instance. diff --git a/stubs/Auth/ResetPasswordController.stub b/stubs/Auth/ResetPasswordController.stub index b1726a3..fe965b2 100644 --- a/stubs/Auth/ResetPasswordController.stub +++ b/stubs/Auth/ResetPasswordController.stub @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\ResetsPasswords; class ResetPasswordController extends Controller @@ -26,5 +25,5 @@ class ResetPasswordController extends Controller * * @var string */ - protected $redirectTo = RouteServiceProvider::HOME; + protected $redirectTo = '/home'; } diff --git a/stubs/Auth/VerificationController.stub b/stubs/Auth/VerificationController.stub index 5e749af..23a43a8 100644 --- a/stubs/Auth/VerificationController.stub +++ b/stubs/Auth/VerificationController.stub @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; -use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\VerifiesEmails; class VerificationController extends Controller @@ -26,7 +25,7 @@ class VerificationController extends Controller * * @var string */ - protected $redirectTo = RouteServiceProvider::HOME; + protected $redirectTo = '/home'; /** * Create a new controller instance. From f05765fe87958970d6cf5f7be40cad8254476d7e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 12:10:54 +0000 Subject: [PATCH 04/12] Injects `Controller` stub --- src/Auth/stubs/controllers/Controller.php | 12 ++++++++++++ src/AuthCommand.php | 19 +++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/Auth/stubs/controllers/Controller.php diff --git a/src/Auth/stubs/controllers/Controller.php b/src/Auth/stubs/controllers/Controller.php new file mode 100644 index 0000000..8fa10da --- /dev/null +++ b/src/Auth/stubs/controllers/Controller.php @@ -0,0 +1,12 @@ +option('force')) { if ($this->components->confirm("The [HomeController.php] file already exists. Do you want to replace it?")) { - file_put_contents($controller, $this->compileControllerStub()); + file_put_contents($controller, $this->compileControllerStub('HomeController')); } } else { - file_put_contents($controller, $this->compileControllerStub()); + file_put_contents($controller, $this->compileControllerStub('HomeController')); + } + + $baseController = app_path('Http/Controllers/Controller.php'); + + if (file_exists($baseController) && ! $this->option('force')) { + if ($this->components->confirm("The [Controller.php] file already exists. Do you want to replace it?")) { + file_put_contents($baseController, $this->compileControllerStub('Controller')); + } + } else { + file_put_contents($baseController, $this->compileControllerStub('Controller')); } file_put_contents( @@ -138,14 +148,15 @@ protected function exportBackend() /** * Compiles the "HomeController" stub. * + * @param string $stub * @return string */ - protected function compileControllerStub() + protected function compileControllerStub($stub) { return str_replace( '{{namespace}}', $this->laravel->getNamespace(), - file_get_contents(__DIR__.'/Auth/stubs/controllers/HomeController.stub') + file_get_contents(__DIR__.'/Auth/stubs/controllers/'.$stub.'.stub') ); } From b3fa5a601ace3bdd52442728282fd1b92cc44f79 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 12:22:35 +0000 Subject: [PATCH 05/12] Adds missing `.php` suffix --- src/AuthCommand.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AuthCommand.php b/src/AuthCommand.php index d9406bf..2102c59 100644 --- a/src/AuthCommand.php +++ b/src/AuthCommand.php @@ -117,20 +117,20 @@ protected function exportBackend() if (file_exists($controller) && ! $this->option('force')) { if ($this->components->confirm("The [HomeController.php] file already exists. Do you want to replace it?")) { - file_put_contents($controller, $this->compileControllerStub('HomeController')); + file_put_contents($controller, $this->compileControllerStub('HomeController.php')); } } else { - file_put_contents($controller, $this->compileControllerStub('HomeController')); + file_put_contents($controller, $this->compileControllerStub('HomeController.php')); } $baseController = app_path('Http/Controllers/Controller.php'); if (file_exists($baseController) && ! $this->option('force')) { if ($this->components->confirm("The [Controller.php] file already exists. Do you want to replace it?")) { - file_put_contents($baseController, $this->compileControllerStub('Controller')); + file_put_contents($baseController, $this->compileControllerStub('Controller.php')); } } else { - file_put_contents($baseController, $this->compileControllerStub('Controller')); + file_put_contents($baseController, $this->compileControllerStub('Controller.php')); } file_put_contents( From bb2d665358871cca33894c04805f7000c6733a84 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 12:25:44 +0000 Subject: [PATCH 06/12] Fixes stubs --- .../stubs/controllers/{Controller.php => Controller.stub} | 0 src/AuthCommand.php | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/Auth/stubs/controllers/{Controller.php => Controller.stub} (100%) diff --git a/src/Auth/stubs/controllers/Controller.php b/src/Auth/stubs/controllers/Controller.stub similarity index 100% rename from src/Auth/stubs/controllers/Controller.php rename to src/Auth/stubs/controllers/Controller.stub diff --git a/src/AuthCommand.php b/src/AuthCommand.php index 2102c59..d9406bf 100644 --- a/src/AuthCommand.php +++ b/src/AuthCommand.php @@ -117,20 +117,20 @@ protected function exportBackend() if (file_exists($controller) && ! $this->option('force')) { if ($this->components->confirm("The [HomeController.php] file already exists. Do you want to replace it?")) { - file_put_contents($controller, $this->compileControllerStub('HomeController.php')); + file_put_contents($controller, $this->compileControllerStub('HomeController')); } } else { - file_put_contents($controller, $this->compileControllerStub('HomeController.php')); + file_put_contents($controller, $this->compileControllerStub('HomeController')); } $baseController = app_path('Http/Controllers/Controller.php'); if (file_exists($baseController) && ! $this->option('force')) { if ($this->components->confirm("The [Controller.php] file already exists. Do you want to replace it?")) { - file_put_contents($baseController, $this->compileControllerStub('Controller.php')); + file_put_contents($baseController, $this->compileControllerStub('Controller')); } } else { - file_put_contents($baseController, $this->compileControllerStub('Controller.php')); + file_put_contents($baseController, $this->compileControllerStub('Controller')); } file_put_contents( From 7c571004fc50fdd0fded950b8233c4ea583e2476 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 12:42:25 +0000 Subject: [PATCH 07/12] Overrides service provider if needed --- .../stubs/providers/AppServiceProvider.stub | 25 +++++++++++++++++++ src/AuthCommand.php | 25 ++++++++++++++----- 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 src/Auth/stubs/providers/AppServiceProvider.stub diff --git a/src/Auth/stubs/providers/AppServiceProvider.stub b/src/Auth/stubs/providers/AppServiceProvider.stub new file mode 100644 index 0000000..941ec59 --- /dev/null +++ b/src/Auth/stubs/providers/AppServiceProvider.stub @@ -0,0 +1,25 @@ + '/'); + } +} diff --git a/src/AuthCommand.php b/src/AuthCommand.php index d9406bf..5cfcb70 100644 --- a/src/AuthCommand.php +++ b/src/AuthCommand.php @@ -117,20 +117,33 @@ protected function exportBackend() if (file_exists($controller) && ! $this->option('force')) { if ($this->components->confirm("The [HomeController.php] file already exists. Do you want to replace it?")) { - file_put_contents($controller, $this->compileControllerStub('HomeController')); + file_put_contents($controller, $this->compileStub('controllers/HomeController')); } } else { - file_put_contents($controller, $this->compileControllerStub('HomeController')); + file_put_contents($controller, $this->compileStub('controllers/HomeController')); } $baseController = app_path('Http/Controllers/Controller.php'); if (file_exists($baseController) && ! $this->option('force')) { if ($this->components->confirm("The [Controller.php] file already exists. Do you want to replace it?")) { - file_put_contents($baseController, $this->compileControllerStub('Controller')); + file_put_contents($baseController, $this->compileStub('controllers/Controller')); } } else { - file_put_contents($baseController, $this->compileControllerStub('Controller')); + file_put_contents($baseController, $this->compileStub('controllers/Controller')); + } + + if (class_exists('Illuminate\Auth\Middleware\RedirectIfAuthenticated') + && method_exists('Illuminate\Auth\Middleware\RedirectIfAuthenticated', 'redirectUsing')) { + $appProvider = app_path('Providers/AppServiceProvider.php'); + + if (file_exists($appProvider) && ! $this->option('force')) { + if ($this->components->confirm("The [AppServiceProvider.php] file already exists. Do you want to replace it?")) { + file_put_contents($appProvider, $this->compileStub('providers/AppServiceProvider')); + } + } else { + file_put_contents($appProvider, $this->compileStub('providers/AppServiceProvider')); + } } file_put_contents( @@ -151,12 +164,12 @@ protected function exportBackend() * @param string $stub * @return string */ - protected function compileControllerStub($stub) + protected function compileStub($stub) { return str_replace( '{{namespace}}', $this->laravel->getNamespace(), - file_get_contents(__DIR__.'/Auth/stubs/controllers/'.$stub.'.stub') + file_get_contents(__DIR__.'/Auth/stubs/'.$stub.'.stub') ); } From 6c69a337ed9e8f64af6dd51209a07fa9078d7ecd Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 12:43:42 +0000 Subject: [PATCH 08/12] Fixes namespace --- src/Auth/stubs/providers/AppServiceProvider.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Auth/stubs/providers/AppServiceProvider.stub b/src/Auth/stubs/providers/AppServiceProvider.stub index 941ec59..e1dde66 100644 --- a/src/Auth/stubs/providers/AppServiceProvider.stub +++ b/src/Auth/stubs/providers/AppServiceProvider.stub @@ -3,7 +3,7 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; -use Illuminate\Auth\Middleware\redirectUsing; +use Illuminate\Auth\Middleware\RedirectIfAuthenticated; class AppServiceProvider extends ServiceProvider { From 806e86ea238fc146280f897c566b7b00b94f8b9f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 12:51:03 +0000 Subject: [PATCH 09/12] Redirects home --- src/Auth/stubs/providers/AppServiceProvider.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Auth/stubs/providers/AppServiceProvider.stub b/src/Auth/stubs/providers/AppServiceProvider.stub index e1dde66..9d9fa91 100644 --- a/src/Auth/stubs/providers/AppServiceProvider.stub +++ b/src/Auth/stubs/providers/AppServiceProvider.stub @@ -20,6 +20,6 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - RedirectIfAuthenticated::redirectUsing(fn () => '/'); + RedirectIfAuthenticated::redirectUsing(fn () => '/home'); } } From 5e12cd1e683d8c6f5860a73f8846a23b415ab836 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 13:10:49 +0000 Subject: [PATCH 10/12] docs --- src/AuthCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuthCommand.php b/src/AuthCommand.php index 5cfcb70..465577f 100644 --- a/src/AuthCommand.php +++ b/src/AuthCommand.php @@ -159,7 +159,7 @@ protected function exportBackend() } /** - * Compiles the "HomeController" stub. + * Compiles the given stub. * * @param string $stub * @return string From 1ed855a0d6b2adeae590eedc79fb8e87922ebb4d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 30 Nov 2023 17:24:55 +0000 Subject: [PATCH 11/12] Installs `2014_10_12_100000_create_password_resets_table` for older Laravel versions --- src/AuthCommand.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AuthCommand.php b/src/AuthCommand.php index 465577f..8061249 100644 --- a/src/AuthCommand.php +++ b/src/AuthCommand.php @@ -144,6 +144,11 @@ protected function exportBackend() } else { file_put_contents($appProvider, $this->compileStub('providers/AppServiceProvider')); } + } else { + copy( + __DIR__.'/../stubs/migrations/2014_10_12_100000_create_password_resets_table.php', + base_path('database/migrations/2014_10_12_100000_create_password_resets_table.php') + ); } file_put_contents( @@ -151,11 +156,6 @@ protected function exportBackend() file_get_contents(__DIR__.'/Auth/stubs/routes.stub'), FILE_APPEND ); - - copy( - __DIR__.'/../stubs/migrations/2014_10_12_100000_create_password_resets_table.php', - base_path('database/migrations/2014_10_12_100000_create_password_resets_table.php') - ); } /** From 95acfd39c37edbc1268ca2c8c75cd9f2cb516b6d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Wed, 27 Dec 2023 16:31:32 +0000 Subject: [PATCH 12/12] Only copies reset passports before Laravel 11 --- .../stubs/providers/AppServiceProvider.stub | 25 ------------------- src/AuthCommand.php | 13 +--------- 2 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 src/Auth/stubs/providers/AppServiceProvider.stub diff --git a/src/Auth/stubs/providers/AppServiceProvider.stub b/src/Auth/stubs/providers/AppServiceProvider.stub deleted file mode 100644 index 9d9fa91..0000000 --- a/src/Auth/stubs/providers/AppServiceProvider.stub +++ /dev/null @@ -1,25 +0,0 @@ - '/home'); - } -} diff --git a/src/AuthCommand.php b/src/AuthCommand.php index 8061249..ed525f6 100644 --- a/src/AuthCommand.php +++ b/src/AuthCommand.php @@ -133,18 +133,7 @@ protected function exportBackend() file_put_contents($baseController, $this->compileStub('controllers/Controller')); } - if (class_exists('Illuminate\Auth\Middleware\RedirectIfAuthenticated') - && method_exists('Illuminate\Auth\Middleware\RedirectIfAuthenticated', 'redirectUsing')) { - $appProvider = app_path('Providers/AppServiceProvider.php'); - - if (file_exists($appProvider) && ! $this->option('force')) { - if ($this->components->confirm("The [AppServiceProvider.php] file already exists. Do you want to replace it?")) { - file_put_contents($appProvider, $this->compileStub('providers/AppServiceProvider')); - } - } else { - file_put_contents($appProvider, $this->compileStub('providers/AppServiceProvider')); - } - } else { + if (! file_exists(database_path('migrations/0001_01_01_000000_create_users_table.php'))) { copy( __DIR__.'/../stubs/migrations/2014_10_12_100000_create_password_resets_table.php', base_path('database/migrations/2014_10_12_100000_create_password_resets_table.php')