Open takanori-matsushita opened 4 years ago
9.1 Remember me 機能 この機能はLaravel Authに標準で実装されているため、省略
リスト 9.21: [remember me] チェックボックスをログインフォームに追加する
@php
$title = 'Log in'
@endphp
@extends('layouts.layout')
@section('content')
<h1>Log in</h1>
<div class="row">
<div class="col-md-6 offset-md-3">
<form action="{{route('login')}}" method="post">
@csrf
@include('shared.error_messages')
<label for="email">Email</label>
<input type="text" name="email" class="form-control" id="session_email" value="{{old('email')}}">
<label for="password">Password</label>
<input type="password" name="password" class="form-control" id="session_password">
//remember_meの追加
<label for="remember" class="checkbox inline">
<input class="form-check-input" type="checkbox" name="remember" id="session_remember_me" {{ old('remember') ? 'checked' : '' }}>
<span>Remember me on this computer</span>
</label>
//ここまで
<input type="submit" class="btn btn-primary" value="Log in!">
</form>
<p>New user? <a href="{{route('users.signup')}}">Sign up now!</a></p>
</div>
</div>
@endsection
リスト 9.22: [remember me] チェックボックスのCSS
resources/sass/_custom.scss
そのままコピペして、以下コマンド実行
$ yarn dev
branch: advanced-login