ここに質問の内容を詳しく書いてください。
Laravel6においてルーティング上での問題
実現したいこと
- [CodeCampGATEで学習しているLaravel6の29章にて、ユーザー登録画面及びログイン画面を表示させたいです。]
発生している問題・エラーメッセージ
URLの/registerを入力した際にビューで設定したユーザー登録画面及びログイン画面を表示させたいのですが、ユーザー登録画面が下記のエラーにより出ません。](https://ddjkaamml8q8x.cloudfront.net/questions/2022-09-07/cf276395-acf7-4947-b9a7-5a7eab0f9fb0.png) View [layouts.not_logged_in] not found. (View: /home/ec2-user/environment/laravel_photo/resources/views/auth/register.blade.php) layouts.not_logged_in was not found.
該当のソースコード
・ルーティングのコード、web.php
php
1<?php 2 3/* 4|-------------------------------------------------------------------------- 5| Web Routes 6|-------------------------------------------------------------------------- 7| 8| Here is where you can register web routes for your application. These 9| routes are loaded by the RouteServiceProvider within a group which 10| contains the "web" middleware group. Now create something great! 11| 12*/ 13Auth::routes(); 14 15Route::get('/', function () { 16 // return view('welcome'); 17 return view('top'); 18}); 19// 投稿一覧 20// Route::get('/posts', 'PostController@index'); 21// // 投稿追加フォーム 22// Route::get('/posts/create', 'PostController@create'); 23// // 投稿追加 24// Route::post('/posts', 'PostController@store'); 25// // 投稿詳細 26// Route::get('/posts/{id}', 'PostController@show'); 27// // 投稿更新フォーム 28// Route::get('/posts/{id}/edit', 'PostController@edit'); 29// // 投稿更新 30// Route::patch('/posts/{id}', 'PostController@update'); 31// // 投稿削除 32// Route::delete('posts', 'PostController@destroy'); 33 34// 上記の7つのルーティングを下の一つで同じ効果にできる 35// postsに関するリソースルーティングを行い、 36// PostControllerの各アクションに紐づける 37Route::resource('posts', 'PostController'); 38 39Route::resource('likes', 'LikeController')->only([ 40 'index', 'store', 'destroy' 41]); 42 43Route::resource('follows', 'FollowController')->only([ 44 'index', 'store', 'destroy' 45]); 46 47Route::get('/folloow', 'FollowController@folloowerIndex'); 48
・ユーザー登録画面のコントローラー、RegisterController.php
php
1<?php 2 3namespace App\Http\Controllers\Auth; 4 5use App\Http\Controllers\Controller; 6use App\Providers\RouteServiceProvider; 7use App\User; 8use Illuminate\Foundation\Auth\RegistersUsers; 9use Illuminate\Support\Facades\Hash; 10use Illuminate\Support\Facades\Validator; 11 12class RegisterController extends Controller 13{ 14 /* 15 |-------------------------------------------------------------------------- 16 | Register Controller 17 |-------------------------------------------------------------------------- 18 | 19 | This controller handles the registration of new users as well as their 20 | validation and creation. By default this controller uses a trait to 21 | provide this functionality without requiring any additional code. 22 | 23 */ 24 // RegisterUsers トレイトを利用 25 use RegistersUsers; 26 27 /** 28 * Where to redirect users after registration. 29 * 30 * @var string 31 */ 32 // ユーザー登録後はホーム画面に移動 33 protected $redirectTo = RouteServiceProvider::HOME; 34 35 /** 36 * Create a new controller instance. 37 * 38 * @return void 39 */ 40 // 未ログインであることを確認 41 public function __construct() 42 { 43 $this->middleware('guest'); 44 } 45 46 /** 47 * Get a validator for an incoming registration request. 48 * 49 * @param array $data 50 * @return \Illuminate\Contracts\Validation\Validator 51 */ 52 // ユーザー登録フォームで用いるバリデーションルールを設定 53 protected function validator(array $data) 54 { 55 return Validator::make($data, [ 56 'name' => ['required', 'string', 'max:255'], 57 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 58 'password' => ['required', 'string', 'min:8', 'confirmed'], 59 ]); 60 } 61 62 /** 63 * Create a new user instance after a valid registration. 64 * 65 * @param array $data 66 * @return \App\User 67 */ 68 // ユーザーの生成処理 69 protected function create(array $data) 70 { 71 return User::create([ 72 'name' => $data['name'], 73 'email' => $data['email'], 74 'password' => Hash::make($data['password']), 75 ]); 76 } 77}
ログイン処理画面のコントローラー、Login.Controller.php
php
1<?php 2 3namespace App\Http\Controllers\Auth; 4 5use App\Http\Controllers\Controller; 6use App\Providers\RouteServiceProvider; 7use Illuminate\Foundation\Auth\AuthenticatesUsers; 8 9class LoginController extends Controller 10{ 11 /* 12 |-------------------------------------------------------------------------- 13 | Login Controller 14 |-------------------------------------------------------------------------- 15 | 16 | This controller handles authenticating users for the application and 17 | redirecting them to your home screen. The controller uses a trait 18 | to conveniently provide its functionality to your applications. 19 | 20 */ 21 // AuthenticatesUsers トレイトを利用 22 use AuthenticatesUsers; 23 24 /** 25 * Where to redirect users after login. 26 * 27 * @var string 28 */ 29 // ログイン後はホーム画面に移動 30 protected $redirectTo = RouteServiceProvider::HOME; 31 32 /** 33 * Create a new controller instance. 34 * 35 * @return void 36 */ 37 // ログアウト処理以外では、未ログインであることを確認 38 public function __construct() 39 { 40 $this->middleware('guest')->except('logout'); 41 } 42} 43
ユーザー登録画面のビュー、register.blade.php
php
1@extends('layouts.not_logged_in') 2 3@section('content') 4 <h1>サインアップ</h1> 5 6 <form method="POST" action="{{ route('register') }}"> 7 @csrf 8 <div> 9 <label> 10 ユーザー名: 11 <input type="text" name="name"> 12 </label> 13 </div> 14 15 <div> 16 <label> 17 メールアドレス: 18 <input type="email" name="email"> 19 </label> 20 </div> 21 22 <div> 23 <label> 24 パスワード: 25 <input type="password" name="password"> 26 </label> 27 </div> 28 29 <div> 30 <label> 31 パスワード(確認用): 32 <input type="password" name="password_confirmation" > 33 </label> 34 </div> 35 36 <div> 37 <input type="submit" value="登録"> 38 </div> 39 </form> 40@endsection
ログインフォームのビュー、login.blade.php
php
1@extends('layouts.not_logged_in') 2 3@section('content') 4 <h1>ログイン</h1> 5 6 <form method="POST" action="{{ route('login') }}"> 7 @csrf 8 <div> 9 <label> 10 メールアドレス: 11 <input type="email" name="email"> 12 </label> 13 </div> 14 15 <div> 16 <label> 17 パスワード: 18 <input type="password" name="password" > 19 </label> 20 </div> 21 22 <input type="submit" value="ログイン"> 23 </form> 24@endsection
試したこと
誤字などのチェックや、ルートディレクトリの確認
補足情報(FW/ツールのバージョンなど)
Windows10でAWS Cloud9を使用してLaravel6を学習しています。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。