Laravel-activitylog: Put custom property not working

Created on 3 Oct 2016  路  2Comments  路  Source: spatie/laravel-activitylog

Hi, when I try put custom property to activity not working.

Example:

$lastActivity = Activity::all()->last();
//now $lastActivity->properties ={"attributes":{"name":"name","email":"[email protected]"}}

$lastActivity->properties->put('ip', '127.0.0.1');
//now $lastActivity->properties = {"attributes": "name":"name","email":"[email protected]"}}

The method "put" doesn't update the properties :-(

Thanks!

Most helpful comment

I think this is an Eloquent thing. Does it work if you reassign properties?

$lastActivity = Activity::all()->last();
$lastActivity->properties = $lastActivity->properties->put('ip', '127.0.0.1');

All 2 comments

I think this is an Eloquent thing. Does it work if you reassign properties?

$lastActivity = Activity::all()->last();
$lastActivity->properties = $lastActivity->properties->put('ip', '127.0.0.1');

Oh, yes! Thank you very much! :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BerendSpigt picture BerendSpigt  路  4Comments

TheFrankman picture TheFrankman  路  5Comments

uyab picture uyab  路  4Comments

Hesesses picture Hesesses  路  5Comments

rjcrystal picture rjcrystal  路  5Comments