danyal14 / danyaldk_lumen_activity_log by danyal14

Very simple package to log user activities. Aim is to capture which object was created / updated / deleted by which user. Package it self has no relation implemented and stores whatever is passed.
338
0
1
Package Data
Maintainer Username: danyal14
Maintainer Contact: danyal@hotmail.dk (Danyal Butt)
Package Create Date: 2019-02-18
Package Last Update: 2019-05-12
Language: PHP
License: MIT
Last Refreshed: 2025-02-06 03:13:24
Package Statistics
Total Downloads: 338
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 1
Total Open Issues: 0

Activity Log for Lumen framework

Very simple package to log user activities. Aim is to capture which object was created / updated / deleted by which user. Package it self has no relation implemented and stores whatever is passed.

Developer

Danyal - www.danyal.dk

Installation

You can install the package via composer:

composer require danyaldk/lumen-activity-log

Register package in you Lumen API.

edit: bootstrap/app.php & add fillowing code

$app->register(\DANYALDK\ActivityLog\Providers\ActivityLogServiceProvider::class);

Copy database migration.

This will copy the database migration file file to you api database/migrations folder.

php artisan danyaldk:copy:migration

Run database migration.

This will copy the database migration file file to you api database/migrations folder.

php artisan migrate

Usage

Now when package is configured successfully, you are good to utilize the activity log. Take a look at example MyController.

use DANYALDK\ActivityLog\ActivityLog;
use Illuminate\Http\Request;

/**
 * Class MyController
 *
 * @package App\Http\Controllers
 */
class MyController extends Controller
{
    public function store(Request $request)
    {
        // Example: 
        $object = Model::create([....]);
        
        // Log activity: 
        if ($object->id) {
            ActivityLog::log($request, ['object' => $object, 'user_id' => $user_id, 'message' => 'Object is created successfully']);
        }
    }
}