Package Data | |
---|---|
Maintainer Username: | jeroenbourgois |
Maintainer Contact: | pieter@jackjoe.be (Pieter Michels) |
Package Create Date: | 2017-03-20 |
Package Last Update: | 2019-04-12 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 03:00:21 |
Package Statistics | |
---|---|
Total Downloads: | 986 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 5 |
Total Forks: | 3 |
Total Open Issues: | 1 |
Installation is done with composer, so add the package to yourcomposer.json
file:
"require": {
"jackjoe/activity-log": "0.3.*"
},
Then run composer update
Laravel 5.5 has auto discovery, you are done. If not see below.
Register the service provider and alias in app/config/app.php
. Add the
following to the providers
array:
JackJoe\ActivityLog\ActivityLogServiceProvider::class,
And add this to the aliases
array:
'Activity' => JackJoe\ActivityLog\Models\Activity::class,
To publish this package's configuration, run this from the command line:
php artisan vendor:publish --provider="JackJoe\ActivityLog\ActivityLogServiceProvider"
Note: Migrations are only published; remember to run them when ready.
To run migration to create ActivityLog's table, run this from the command line:
php artisan migrate
Activity::log([
'contentId' => $user->id,
'content' => 'User',
'action' => 'ACTION',
'state' => 'SUCCESS',
'details' => 'Username: ' . $user->username,
'data' => json_encode($data)
]);
The above code will log an activity for the currently logged in user. The IP address will automatically be saved as well.
content
: type of content we are dealing with, can be set to match PHP class,
controller, model, ... It gives us more context where this action has taken
place.contentId
(option): id of content, in case of a modelaction
: method name, sub-action in method, ..state
: state of action such as ERROR
, SUCCESS
, WRONG_CODE
, ...details
: more like meta date about current statedata
: raw data, fetched content, posted content, ...Please see CONTRIBUTING for details.
Based on Regulus/ActivityLog
.
The MIT License (MIT). Please see License File for more information.