Skip to content

Commit 7335d70

Browse files
authored
[develop] Adds L11 support (#257) (#259)
* Adds L11 support * Fixes missing readme * Removes references to `RouteServiceProvider` * Injects `Controller` stub * Adds missing `.php` suffix * Fixes stubs * Overrides service provider if needed * Fixes namespace * Redirects home * docs * Installs `2014_10_12_100000_create_password_resets_table` for older Laravel versions * Only copies reset passports before Laravel 11
1 parent 7fa676b commit 7335d70

11 files changed

+53
-29
lines changed

.github/workflows/tests.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ jobs:
1717
fail-fast: true
1818
matrix:
1919
php: ['8.0', 8.1, 8.2, 8.3]
20-
laravel: [9, 10]
20+
laravel: [9, 10, 11]
2121
exclude:
2222
- php: '8.0'
2323
laravel: 10
24+
- php: '8.0'
25+
laravel: 11
26+
- php: '8.1'
27+
laravel: 11
2428
- php: 8.3
2529
laravel: 9
2630

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Only the latest major version of Laravel UI receives bug fixes. The table below
2121
| [1.x](https://github.com/laravel/ui/tree/1.x) | 5.8, 6.x |
2222
| [2.x](https://github.com/laravel/ui/tree/2.x) | 7.x |
2323
| [3.x](https://github.com/laravel/ui/tree/3.x) | 8.x |
24-
| [4.x](https://github.com/laravel/ui/tree/4.x) | 9.x, 10.x |
24+
| [4.x](https://github.com/laravel/ui/tree/4.x) | 9.x, 10.x, 11.x |
2525

2626
### Installation
2727

composer.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
],
1212
"require": {
1313
"php": "^8.0",
14-
"illuminate/console": "^9.21|^10.0",
15-
"illuminate/filesystem": "^9.21|^10.0",
16-
"illuminate/support": "^9.21|^10.0",
17-
"illuminate/validation": "^9.21|^10.0"
14+
"illuminate/console": "^9.21|^10.0|^11.0",
15+
"illuminate/filesystem": "^9.21|^10.0|^11.0",
16+
"illuminate/support": "^9.21|^10.0|^11.0",
17+
"illuminate/validation": "^9.21|^10.0|^11.0"
1818
},
1919
"require-dev": {
20-
"orchestra/testbench": "^7.0|^8.0",
21-
"phpunit/phpunit": "^9.3"
20+
"orchestra/testbench": "^7.0|^8.0|^9.0",
21+
"phpunit/phpunit": "^9.3|^10.4"
2222
},
2323
"autoload": {
2424
"psr-4": {
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace {{namespace}}Http\Controllers;
4+
5+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
6+
use Illuminate\Foundation\Validation\ValidatesRequests;
7+
use Illuminate\Routing\Controller as BaseController;
8+
9+
class Controller extends BaseController
10+
{
11+
use AuthorizesRequests, ValidatesRequests;
12+
}

src/AuthCommand.php

+23-10
Original file line numberDiff line numberDiff line change
@@ -117,35 +117,48 @@ protected function exportBackend()
117117

118118
if (file_exists($controller) && ! $this->option('force')) {
119119
if ($this->components->confirm("The [HomeController.php] file already exists. Do you want to replace it?")) {
120-
file_put_contents($controller, $this->compileControllerStub());
120+
file_put_contents($controller, $this->compileStub('controllers/HomeController'));
121121
}
122122
} else {
123-
file_put_contents($controller, $this->compileControllerStub());
123+
file_put_contents($controller, $this->compileStub('controllers/HomeController'));
124+
}
125+
126+
$baseController = app_path('Http/Controllers/Controller.php');
127+
128+
if (file_exists($baseController) && ! $this->option('force')) {
129+
if ($this->components->confirm("The [Controller.php] file already exists. Do you want to replace it?")) {
130+
file_put_contents($baseController, $this->compileStub('controllers/Controller'));
131+
}
132+
} else {
133+
file_put_contents($baseController, $this->compileStub('controllers/Controller'));
134+
}
135+
136+
if (! file_exists(database_path('migrations/0001_01_01_000000_create_users_table.php'))) {
137+
copy(
138+
__DIR__.'/../stubs/migrations/2014_10_12_100000_create_password_resets_table.php',
139+
base_path('database/migrations/2014_10_12_100000_create_password_resets_table.php')
140+
);
124141
}
125142

126143
file_put_contents(
127144
base_path('routes/web.php'),
128145
file_get_contents(__DIR__.'/Auth/stubs/routes.stub'),
129146
FILE_APPEND
130147
);
131-
132-
copy(
133-
__DIR__.'/../stubs/migrations/2014_10_12_100000_create_password_resets_table.php',
134-
base_path('database/migrations/2014_10_12_100000_create_password_resets_table.php')
135-
);
136148
}
137149

138150
/**
139-
* Compiles the "HomeController" stub.
151+
* Compiles the given stub.
140152
*
153+
* @param string $stub
141154
* @return string
142155
*/
143-
protected function compileControllerStub()
156+
protected function compileStub($stub)
144157
{
145158
return str_replace(
146159
'{{namespace}}',
147160
$this->laravel->getNamespace(),
148-
file_get_contents(__DIR__.'/Auth/stubs/controllers/HomeController.stub')
161+
file_get_contents(__DIR__.'/Auth/stubs/'.$stub.'.stub')
149162
);
150163
}
151164

stubs/Auth/ConfirmPasswordController.stub

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6-
use App\Providers\RouteServiceProvider;
76
use Illuminate\Foundation\Auth\ConfirmsPasswords;
87

98
class ConfirmPasswordController extends Controller
@@ -26,7 +25,7 @@ class ConfirmPasswordController extends Controller
2625
*
2726
* @var string
2827
*/
29-
protected $redirectTo = RouteServiceProvider::HOME;
28+
protected $redirectTo = '/home';
3029

3130
/**
3231
* Create a new controller instance.

stubs/Auth/LoginController.stub

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6-
use App\Providers\RouteServiceProvider;
76
use Illuminate\Foundation\Auth\AuthenticatesUsers;
87

98
class LoginController extends Controller
@@ -26,7 +25,7 @@ class LoginController extends Controller
2625
*
2726
* @var string
2827
*/
29-
protected $redirectTo = RouteServiceProvider::HOME;
28+
protected $redirectTo = '/home';
3029

3130
/**
3231
* Create a new controller instance.

stubs/Auth/RegisterController.stub

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6-
use App\Providers\RouteServiceProvider;
76
use App\Models\User;
87
use Illuminate\Foundation\Auth\RegistersUsers;
98
use Illuminate\Support\Facades\Hash;
@@ -29,7 +28,7 @@ class RegisterController extends Controller
2928
*
3029
* @var string
3130
*/
32-
protected $redirectTo = RouteServiceProvider::HOME;
31+
protected $redirectTo = '/home';
3332

3433
/**
3534
* Create a new controller instance.

stubs/Auth/ResetPasswordController.stub

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6-
use App\Providers\RouteServiceProvider;
76
use Illuminate\Foundation\Auth\ResetsPasswords;
87

98
class ResetPasswordController extends Controller
@@ -26,5 +25,5 @@ class ResetPasswordController extends Controller
2625
*
2726
* @var string
2827
*/
29-
protected $redirectTo = RouteServiceProvider::HOME;
28+
protected $redirectTo = '/home';
3029
}

stubs/Auth/VerificationController.stub

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6-
use App\Providers\RouteServiceProvider;
76
use Illuminate\Foundation\Auth\VerifiesEmails;
87

98
class VerificationController extends Controller
@@ -26,7 +25,7 @@ class VerificationController extends Controller
2625
*
2726
* @var string
2827
*/
29-
protected $redirectTo = RouteServiceProvider::HOME;
28+
protected $redirectTo = '/home';
3029

3130
/**
3231
* Create a new controller instance.

tests/AuthBackend/ThrottleLoginsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function it_can_generate_throttle_key(string $email, string $expectedEmai
2828
$this->assertSame($expectedEmail . '|192.168.0.1', $method->invoke($throttle, $request));
2929
}
3030

31-
public function emailProvider(): array
31+
public static function emailProvider(): array
3232
{
3333
return [
3434
'lowercase special characters' => ['ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ', '[email protected]'],

0 commit comments

Comments
 (0)