dev-master
9999999-devThis library can be used to log the activities or requests to track later.
The Requires
- php >=5.5.9
The Development Requires
This library can be used to log the activities or requests to track later.
, (*1)
Eyepax IT Consulting (Pvt) Ltd , (*2)
Install with composer., (*3)
composer require "eyepax/activity_log:dev-master" php artisan vendor:publish php artisan migrate
Now, a table should have been created named "trn_activity_log". This is where all the activities are logged. Also, a config file named "activity_log.php" will also be created inside config/ folder. You can add activities as key value pair, to identify the activity by ID later. Because, in the table, we store only the activity ID., (*4)
Then, add the ActivityLogServiceProvider class in the providers section in config/app.php file., (*5)
Eyepax\ActivityLogServiceProvider::class
Then, add the ActivityLog Facade in the aliases section in config/app.php file., (*6)
'ActivityLog' => Eyepax\Facades\ActivityLog::class
This is designed to use with ease, with configurable fields. The below table explains on the fields., (*7)
# | Field | Description | Required/Optional | Default value |
---|---|---|---|---|
1 | performed_user_id | If there are any type of user who performed, then that specific type user ID (Ex: Member/Company) | Optional | 0 |
2 | performed_user_type | If there are any type of user who performed, then type ID (Ex: Member/Company) | Required | |
3 | performed_user_account_id | Users table ID, who performed the action | Required | |
4 | action_user_account_id | Users table ID, who receives the action | Optional | 0 |
5 | action_user_id | If there are any type of user who receives the effect from action, then that specific type user ID (Ex: Member/Company) | Optional | 0 |
6 | action_user_type | If there are any type of user who receives the effect from action, then type ID (Ex: Member/Company) | Optional | 0 |
7 | action_id | Activity ID (Can check activity_log.php config file) | Required | |
8 | platform_type | If the application has different sections, then the specific platform type (Ex: Portal A, Portal B) | Optional | null |
9 | action_data | JSON encoded array of input data | Required | |
10 | action_admin_user_id | If admin performs the activity, then admin user's ID | Optional | null |
11 | api_type | Whether it is admin or front end (1 - Admin, 2 - Front end) | Optional | 1 |
Add this in the top of the file, where you use ActivityLog., (*8)
use Eyepax\ActivityLog;, (*9)
Then, just add the below code, where you want to log the activity. You can add the relevant fields from the above table., (*10)
ActivityLog::log(['action_data' => [ 'data' => Input::all() ]]);
ActivityLog::logMultiples([ ['action_data' => ['data' => Input::all()]], ['action_data' => ['data' => Input::all()]] ]);
ActivityLog::getLogs($params, $page, $itemsPerPage);
$params - Array of filters. Field keys in the above table (except action_data) can be set here. Additionally, These keys can be set. 1. "after": Datetime filed, which will give logs after the given time. 2. "before": Datetime filed, which will give logs before the given time. $page - Starts from 1. (Default: 1) $itemsPerPage - Default is 20.
ActivityLog::getLogDetails($logId);
This library can be used to log the activities or requests to track later.