Created
October 22, 2020 10:13
-
-
Save opejovic/a9b01bdd236ea6f05a1ecb33dec94644 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Listeners; | |
use Illuminate\Http\Request; | |
use Illuminate\Auth\Events\Registered; | |
use Illuminate\Queue\InteractsWithQueue; | |
use Illuminate\Contracts\Queue\ShouldQueue; | |
class SaveIpAddress | |
{ | |
/** | |
* The request instance. | |
* | |
* @var Illuminate\Http\Request | |
*/ | |
protected $request; | |
/** | |
* Create the event listener. | |
* | |
* @return void | |
*/ | |
public function __construct(Request $request) | |
{ | |
$this->request = $request; | |
} | |
/** | |
* Handle the event. | |
* | |
* @param Registered $event | |
* @return void | |
*/ | |
public function handle(Registered $event) | |
{ | |
$event->user->saveIp($this->request->ip()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment