發表文章

目前顯示的是 2016的文章

5. 登入時加入時間及IP位址

如果有安裝   3. Sentinel 2.0 用戶認證應用 : 由於Sentinel 已經有登入的時間欄位了,所以我們僅需要追加IP 開啓 /database/migrations/2014_07_02_230147_migration_cartalyst_sentinel.php 在users table內增加登入的時間: $table->string('last_login')->nullable(); $table->string('ip_address')->nullable(); 開啓 /vendor/cartalyst/sentinel/src/Users/IlluminateUserRepository.php find: namespace Cartalyst\Sentinel\Users; add after: use Illuminate\Support\Facades\Request; find : $user->last_login = Carbon::now(); add after : $user->ip_address = Request::ip(); 如果你裝的是Laravel 提供的預設 user : 這邊會有兩種版本,首先是Laravel 5.2: 開啓 /vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php 找到 public function login(AuthenticatableContract $user, $remember = false) if ($remember) { $this->createRememberTokenIfDoesntExist($user); $this->queueRecallerCookie($user); } // 寫入登入IP & 時間 $this->provider->updateUserInfo($user); 開啓 /vendor/l