snipe-it/app/Listeners/LogSuccessfulLogin.php
Martin Meredith e3e0d57f56 Minor code cleanup bits and bobs (#6805)
* Add IDE Helper files

* Cleanup imports

- Alphabetises imports
- Removes unused imports

* Add Platform requirements

* Move filling asset into block where asset exists

* Remove duplicate array keys
2019-03-13 20:12:03 -07:00

49 lines
889 B
PHP

<?php
namespace App\Listeners;
use Carbon\Carbon;
use DB;
use Illuminate\Auth\Events\Login;
class LogSuccessfulLogin
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param Login $event
* @return void
*/
public function handle(Login $event)
{
$now = new Carbon();
try {
DB::table('login_attempts')->insert(
[
'username' => $event->user->username,
'user_agent' => request()->header('User-Agent'),
'remote_ip' => request()->ip(),
'successful' => 1,
'created_at' => $now,
]
);
} catch (\Exception $e) {
\Log::debug($e);
}
}
}