mercredi 24 mai 2017

A simple event listener in laravel

I have a small app that i dont see it growing beyond a couple of pages so for an event, i decided to have the event in the router web.php

This is the code

Event::listen('simpleEvent', function($user){ 
$user->last_login = new DateTime;
$user->save();
});

I want to use the event on a particular method

public function getLogin(){
$user = User::find(1);
$device = $agent->device();
$platform = $agent->platform();
$browser = $agent->browser();
$ip = Request::ip();

Event::fire('simpleEvent','[$user]);

}

My question is, how do i pass the variables from getLogin to the event in the router?. Right now i am only passing the user



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2qP8Mp9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire