PHPackages                             rajtika/mongovity - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. rajtika/mongovity

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

rajtika/mongovity
=================

Application activity log with mongodb

v2.0.7(3w ago)01841MITPHPPHP ^8.4

Since Jun 11Pushed 3w ago1 watchersCompare

[ Source](https://github.com/jewel-rana/laravel-activity-mongodb)[ Packagist](https://packagist.org/packages/rajtika/mongovity)[ RSS](/packages/rajtika-mongovity/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (9)Used By (0)

Welcome to mongovity package
============================

[](#welcome-to-mongovity-package)

Application activity logging for Laravel using MongoDB.

Requirements
------------

[](#requirements)

- PHP 8.4+
- Laravel 12+
- [mongodb/laravel-mongodb](https://github.com/mongodb/laravel-mongodb) (official MongoDB Laravel integration)
- PHP `mongodb` extension (`pecl install mongodb`)

Upgrading from jenssegers/mongodb
---------------------------------

[](#upgrading-from-jenssegersmongodb)

This package previously depended on the abandoned `jenssegers/mongodb` package. It now uses the officially maintained `mongodb/laravel-mongodb` package.

In your Laravel application:

1. Remove the old package and install the official one:

```
composer remove jenssegers/mongodb
composer require mongodb/laravel-mongodb
```

2. Update your MongoDB model imports from:

```
use Jenssegers\Mongodb\Eloquent\Model;
```

to:

```
use MongoDB\Laravel\Eloquent\Model;
```

3. Update `config/database.php` if needed. The service provider is auto-discovered as `MongoDB\Laravel\MongoDBServiceProvider`.
4. Upgrade this package to the latest version:

```
composer require rajtika/mongovity
```

No changes are required to your mongovity usage (`ActivityTrait`, `Mongovity` service, or facade). Existing activity log data remains compatible.

Installation
------------

[](#installation)

```
composer require rajtika/mongovity
php artisan vendor:publish --tag=mongovity-config
```

Implementation
--------------

[](#implementation)

- Set your MongoDB connection and connection name in the `mongovity.php` config file.
- If you want to log all model activity automatically, follow the instructions below.

```
// Add ActivityTrait to the model you want to log
use Rajtika\Mongovity\Contracts\ActivityTrait;

// Log only specific attributes
protected static $logAttributes = ['name', 'email', 'status'];

// Or log fillable / all non-guarded attributes (for $guarded-only models)
protected static $logFillable = true;

// Skip logging when nothing changed on update
protected static $logOnlyDirty = true;

// Custom log message per event
public function getDescriptionForEvent(string $eventName): string
{
    return "MyModel {$eventName}";
}

// You can define specific events to be logged
protected $recordEvents = [
    'created',
    'updated',
    'deleted',
    'restored'
];
/** -----------OR--------- **/
protected $loggableEvents = [
    'created',
    'updated',
    'deleted',
    'restored'
];

// If you want to save a custom activity log
use Rajtika\Mongovity\Services\Mongovity;

app(Mongovity::class)
    ->by(Auth::user()) // Required *
    ->on(TestModel::find(1)) // optional
    ->event('created') // optional
    ->log('Your custom message');

/** OR **/
use Rajtika\Mongovity\Facades\Mongovity;

Mongovity::by(User::first())->log('Custom message');
```

If your user table has `first_name` and `last_name`, add this accessor to log the user name:

```
public function getNameAttribute()
{
    return $this->first_name . ' ' . $this->last_name;
}
```

If your user table uses a column other than `mobile`, add this accessor:

```
public function getMobileAttribute()
{
    return $this->mobile_number;
}
```

To access the built-in activity log UI, assign the `admin` role or the `activity_logs` permission to the user (when using Spatie Laravel Permission).

Notes
-----

[](#notes)

- Activity logging requires an authenticated user (`Auth::check()`).
- Use Eloquent `save()` / instance `update()` on a model. Mass updates such as `Model::where()->update()` do not fire model events and will not be logged.

Configuration
-------------

[](#configuration)

KeyDescriptionDefault`connection_name`MongoDB database connection`mongodb``collection_name`MongoDB collection for logs`activity_logs``causer_model`User model class for causer references`App\Models\User``log_name`Application log identifier`APP_NAME``route_middleware`Middleware for mongovity routes`['web', 'auth']``index_route_middleware`Permission middleware for the log UI`role_or_permission:admin|activity_logs``layout`App layout view for embedding the log page`null` (standalone page)`content_section`Blade section for page content`content``styles_stack`Blade stack for page styles`styles``scripts_stack`Blade stack for page scripts`scripts``skip_daterangepicker_assets`Skip Moment.js / DateRangePicker CDN assets`false`### Avoid jQuery / DataTables conflicts

[](#avoid-jquery--datatables-conflicts)

By default, the log page renders as a standalone HTML page with its own CDN assets. That can break your application dropdowns and plugins when the page is opened inside your app.

Set your application layout in `config/mongovity.php`:

```
'layout' => 'layouts.app',
'content_section' => 'content',
'styles_stack' => 'styles',
'scripts_stack' => 'scripts',
```

Your layout must already load:

- jQuery
- Bootstrap (v4 or v5)
- DataTables
- Moment.js and DateRangePicker (or leave `skip_daterangepicker_assets` as `false`)

Example in your layout:

```
@stack('styles')
...
@yield('content')
...
@stack('scripts')
```

Publish and customize the view if your stack names differ:

```
php artisan vendor:publish --tag=mongovity-views
```

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance95

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

23d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9dcf443dff096d3af939a7f000435227ec4b2487a8c9a0bad221731e088f97b?d=identicon)[jewelrana.dev](/maintainers/jewelrana.dev)

---

Top Contributors

[![jewel-rana](https://avatars.githubusercontent.com/u/23020274?v=4)](https://github.com/jewel-rana "jewel-rana (37 commits)")[![jewelnewroz](https://avatars.githubusercontent.com/u/88371303?v=4)](https://github.com/jewelnewroz "jewelnewroz (7 commits)")

### Embed Badge

![Health badge](/badges/rajtika-mongovity/health.svg)

```
[![Health](https://phpackages.com/badges/rajtika-mongovity/health.svg)](https://phpackages.com/packages/rajtika-mongovity)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[illuminate/log

The Illuminate Log package.

6225.3M623](/packages/illuminate-log)[spatie/laravel-flare

Send Laravel errors to Flare

111.4M7](/packages/spatie-laravel-flare)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
