### login.blade.php
resources/views/auth/login.blade.php
-> 一応、login_cp.blade.phpでコピーを取っておきます。
-> 日本語化しながら、何が書かれているのか確認していきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | <form method= "POST" action= "{{ route('login') }}" > @csrf <div class = "form-group row" > <label for = "email" class = "col-md-4 col-form-label text-md-right" >{{ __( 'メールアドレス' ) }}</label> <div class = "col-md-6" > <input id= "email" type= "email" class = "form-control @error('email') is-invalid @enderror" name= "email" value= "{{ old('email') }}" required autocomplete= "email" autofocus> @error( 'email' ) <span class = "invalid-feedback" role= "alert" > <strong>{{ $message }}</strong> </span> @enderror </div> </div> <div class = "form-group row" > <label for = "password" class = "col-md-4 col-form-label text-md-right" >{{ __( 'パスワード' ) }}</label> <div class = "col-md-6" > <input id= "password" type= "password" class = "form-control @error('password') is-invalid @enderror" name= "password" required autocomplete= "current-password" > @error( 'password' ) <span class = "invalid-feedback" role= "alert" > <strong>{{ $message }}</strong> </span> @enderror </div> </div> <div class = "form-group row" > <div class = "col-md-6 offset-md-4" > <div class = "form-check" > <input class = "form-check-input" type= "checkbox" name= "remember" id= "remember" {{ old( 'remember' ) ? 'checked' : '' }}> <label class = "form-check-label" for = "remember" > {{ __( 'ログイン状態を記憶' ) }} </label> </div> </div> </div> <div class = "form-group row mb-0" > <div class = "col-md-8 offset-md-4" > <button type= "submit" class = "btn btn-primary" > {{ __( 'ログイン' ) }} </button> @ if (Route::has( 'password.request' )) <a class = "btn btn-link" href= "{{ route('password.request') }}" > {{ __( 'パスワードを忘れた方はこちら' ) }} </a> @ endif </div> </div> </form> |
– FormはPostメソッドで、actionはroute(‘login’)
– メールのnameはemail
– パスワードのnameはpassword
– remember meのnameはremember
– パスワード再発行のリンク先はroute(‘password.request’)
– エラー時には、input formにis-invalidのclassを付けている
### エラーメッセージの日本語化
config/app.php
1 | 'locale' => 'ja' , |
resources/lang/ja/auth.php
※en/auth.phpをコピー。ログインのエラーメッセージはvalidation.phpとは異なるので注意が必要
1 2 3 4 | // 'failed' => 'These credentials do not match our records.', // 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 'failed' => '認証情報が記録と一致しません。' , 'throttle' => 'ログイン試行が規定回数を超えました。:seconds秒後に再開できます。' , |
$ php artisan config:cache
同様に、resources/views/auth/passwordsのemail, resetと、resources/lang/ja/のpasswordsを編集していきます。
verify.blade.phpと/passwords/confirm.blade.phpは、laravel5.7系から実装された、Email Verification機能。必要に応じて実装。