0
私のsite.login履歴へのユーザーログインがテーブルlogin_history
に保存されるときにログイン履歴を作成したいと思います。ユーザログインを以下に示す。電子メールとパスワードを使用してログイン中にデータベースにログイン履歴を作成するにはどうすればよいですか?
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class LoginHistory extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('login_history', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('ip')->default(false);
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('login_history');
}
}
:https://laravel.com/docs/5.0/extending#authentication
:
@extends('site')
{{-- Web site Title --}}
@section('title') {{{ trans('site/user.login') }}} :: @parent @stop
{{-- Content --}}
@section('content')
<article>
<div class="container">
<div id="loginbox" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">Login</div>
<div style="float:right; font-size: 80%; position: relative; top:-20px">
<a target="blank" href="{{ url('password/email')}}">
Forgot password?
</a>
</div>
</div>
<div style="padding-top:30px" class="panel-body" >
<div style="display:none" id="login-alert" class="alert alert-danger col-sm-12">
</div>
@include('errors.list')
<form class="form-horizontal" role="form" method="POST" action="{{ URL::to('/user/login') }}" autocomplete="off">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon">
<i class="glyphicon glyphicon-user"></i>
</span>
<input type="email" class="form-control" required placeholder="enter your login email" name="email" value="{{ old('email') }}">
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon">
<i class="glyphicon glyphicon-lock"></i>
</span>
<input type="password" required placeholder="enter your login password" class="form-control" name="password">
</div>
<div class="input-group">
<div class="checkbox">
<label>
<input id="login-remember" type="checkbox" name="remember" value="1">
Remember me
</label>
</div>
</div>
<div style="margin-top:10px" class="form-group">
<div class="col-sm-12 controls">
<button type="submit" class="btn btn-default" >
Login
</button>
<!-- <a id="btn-fblogin" href="#" class="btn btn-primary">Login with Facebook</a> -->
</div>
</div>
<div class="form-group">
<div class="col-md-12 control">
<div style="border-top: 1px solid #ccc; padding-top:15px; font-size:85%" >
Don't have an account!
<a href="{{ url('register') }}">Create an account</a>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</article>
@endsection