Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

spatie activity log sample

activity()
   ->performedOn($anEloquentModel)
   ->causedBy($user)
   ->withProperties(['customProperty' => 'customValue'])
   ->log('Look mum, I logged something');

$lastLoggedActivity = Activity::all()->last();

$lastLoggedActivity->subject; //returns an instance of an eloquent model
$lastLoggedActivity->causer; //returns an instance of your user model
$lastLoggedActivity->getExtraProperty('customProperty'); //returns 'customValue'
$lastLoggedActivity->description; //returns 'Look mum, I logged something'
Source by spatie.be #
 
PREVIOUS NEXT
Tagged: #spatie #activity #log #sample
ADD COMMENT
Topic
Name
9+5 =