やりたいこと
認証とかの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ファイルにまとめたりしても良いかも