I have a method and in it i have some user tracking code
public function settings(Request $request)
{
$id = Auth::id();
$now = new DateTime();
$page = 'Settings Page';
$monitor = new Monitoring;
$users_full_names = Auth::user()->users_full_names;
$country = 'unseen';
$device = $agent->device();
$platform = $agent->platform();
$browser = $agent->browser();
$date = $now->format('Y-m-d H:i:s');
$time = time();
$ip = $request->ip();
$data = compact('users_full_names','page','country','time','date','monitor','id', 'device', 'platform', 'browser', 'ip');
Event::fire('simpleEvent', $data, $monitor);
$uid = Auth::id();
$settings = Settings::where('user_id','=',Auth::id())->first();
return view('text.settings',compact('settings'));
}
The method has this line that passes the data to the event
Event::fire('simpleEvent', $data, $monitor);
that i have defined. This is the event code that i have in web.php
Event::listen('simpleEvent', function($data,$monitor){
$monitor->monitoring_user_id = Auth::id();
$monitor->monitoring_user_names = $data->users_full_names;
$monitor->monitoring_page_visited = $data->page;
$monitor->monitoring_ip = $data->ip;
$monitor->monitoring_date_of_visit = $data->date;
$monitor->monitoring_time_of_visit = $data->time;
$monitor->monitoring_country = $data->country;
$monitor->monitoring_date = $data->date;
$monitor->monitoring_device = $data->platform;
$monitor->save();
});
When i run the code i get this error
at HandleExceptions->handleError(2, 'Attempt to assign property of non-object', '/var/www/html/letextify/routes/web.php', 14, array('data' => 'Radagast', 'monitor' => 'Successfully Logged In')) in web.php line 14
this is line 14
$monitor->monitoring_user_id = Auth::id();
How can correct the error?.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rXCgyS
via IFTTT
Aucun commentaire:
Enregistrer un commentaire