やりたいこと
認証とかのURLを変更したい
やりかた
Fortify
FortifyServiceProviderのregisterメソッドにFortify::ignoreRoutes();を追加。
~略~
class FortifyServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
Fortify::ignoreRoutes();
}
~略~
routesフォルダ内にfortify.phpを作成する。
vendor\laravel\fortify\routes\routes.phpの中身をコピーして先ほど作成したfortify.phpに貼り付ける。
(fortifyはなぜかpublishが用意されていない)
あとはRouteServiceProvideにルーティングとして登録する。
class RouteServiceProvider extends ServiceProvider
{
~ 省略 ~
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
// 追加
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/fortify.php'));
});
}
あとはよしなにルーティングをいじる。
JetStream
JetstreamServiceProviderのregisterメソッドにJetstream::ignoreRoutes();を追加。
~省略~
class JetstreamServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
Jetstream::ignoreRoutes();
}
Jetstreamのルーティングファイルを公開する。
php artisan vendor:publish --tag=jetstream-routes
あとはRouteServiceProvideにルーティングとして登録する。
class RouteServiceProvider extends ServiceProvider
{
~ 省略 ~
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/fortify.php'));
// 追加
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/jetstream.php'));
});
}
あとはよしなにルーティングをいじる。
認証系のルーティングでauthにして1ファイルにまとめたりしても良いかも