未ログインユーザーに記事投稿画面を表示しないようにするためには、
web.php
Route::resource('/articles', 'ArticleController')->except(['index'])->middleware('auth');
上記にmiddlewareを入れるだけでログインしていない状態であれば、
ログイン画面に遷移されます。
.
└──laravel
└── app
└── Http
└── Middleware
└── Authenticate.php
Authenticate
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}
login
のところをいじれば遷移されるところを、アレンジすることができます。
以上です