PHPackages                             yektadg/laravel-log-activity-mongodb - 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. yektadg/laravel-log-activity-mongodb

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

yektadg/laravel-log-activity-mongodb
====================================

v1(3y ago)143PHP

Since Jun 7Pushed 2y ago3 watchersCompare

[ Source](https://github.com/yektaDG/laravel-log-activity-mongodb)[ Packagist](https://packagist.org/packages/yektadg/laravel-log-activity-mongodb)[ RSS](/packages/yektadg-laravel-log-activity-mongodb/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

laravel-LogActivity-MongoDB
===========================

[](#laravel-logactivity-mongodb)

Log activity inside your Laravel app

[![Log Panel](https://camo.githubusercontent.com/33137ea7d2ab5a32dbca0fb19fbf7ed697f97aa5a4abb00823c8bbe64563c407/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f76312e59326c6b505463354d4749334e6a45785a47597a4d6d5179596a686b4d545133596a51774d5463785a6d597a4e7a63305a5752684d5745304d6a6b7a596a68684e4459354e795a6a6444316e2f713841747948757637516272734a5578645a2f67697068792e676966)](https://camo.githubusercontent.com/33137ea7d2ab5a32dbca0fb19fbf7ed697f97aa5a4abb00823c8bbe64563c407/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f76312e59326c6b505463354d4749334e6a45785a47597a4d6d5179596a686b4d545133596a51774d5463785a6d597a4e7a63305a5752684d5745304d6a6b7a596a68684e4459354e795a6a6444316e2f713841747948757637516272734a5578645a2f67697068792e676966)

initializition config :
-----------------------

[](#initializition-config-)

By default, activities will be saved to the 'yektalog' database in the 'log' collection if no MongoDB configurations are set in the '.env' or 'config/database.php' files. To change the database to your custom one, add the following lines to the '.env' file in your Laravel application :

MONGODB\_CONNECTION=mongodb

MONGODB\_HOST=myhost

MONGODB\_PORT=27017

MONGODB\_DATABASE=yourdatabase

installation :
--------------

[](#installation-)

1. remove 'composer.lock' file and 'vendor' folder
2. run 'composer install' command
3. run 'composer require yektadg/laravel-log-activity-mongodb' command
4. in each models that want to log it's activity you shuld add the following options :

- add YektaLog trait like this :

    ```
      class Test extends Model
          {
              use YektaLog;

              protected $foreignKeys = [
                      'App\Models\Ticket' => 'ticket_id',
                      'App\Models\User' => 'user_id',
              ];
              public function getForeignKeys(){
                      return $this->foreignKeys;
              }
              public function getShowRoute(){
                      return "admin.user.show";
              }
              ....
          }

    ```
- Add a 'protected $foreignKeys' array to your model like this:

    protected $foreignKeys = \[ 'App\\Models\\Ticket' =&gt; 'ticket\_id', 'App\\Models\\User' =&gt; 'user\_id', \]

    'ticket\_id' and 'user\_id' are the referenced fields in this model, and 'App\\Models\\Ticket' and 'App\\Models\\User' are their corresponding classes.
- Add a 'getForeignKeys()' method to your model that returns the 'foreignKeys' variable:

    public function getForeignKeys(){ return $this-&gt;foreignKeys; }

    This method will allow you to retrieve the 'foreignKeys' array.
- Add a 'getShowRoute()' method to your model that returns a route name. this route will saved in database and You can use this method in your views to create a link to the logged object:

    public function getShowRoute(){ return "test.show"; }

    if you don't need this route, return an empty srting like this:

    public function getShowRoute(){ return ""; }

- Use 'Yektadg\\LaravelLogActivityMongodb\\Models\\Log' to access the Log Model like bellow :

    use Yektadg\\LaravelLogActivityMongodb\\Models\\Log; $logs = Log::where('created\_at' ,'!=', null);

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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

Unknown

Total

1

Last Release

1123d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/80994d35760386cd7517cc79b58fed408ac137f4b293272bafebf0255e0ea7bb?d=identicon)[yektaDG](/maintainers/yektaDG)

---

Top Contributors

[![MahsaAflaki](https://avatars.githubusercontent.com/u/122663389?v=4)](https://github.com/MahsaAflaki "MahsaAflaki (12 commits)")[![yektaDG](https://avatars.githubusercontent.com/u/106602247?v=4)](https://github.com/yektaDG "yektaDG (5 commits)")[![Amahsa](https://avatars.githubusercontent.com/u/29246885?v=4)](https://github.com/Amahsa "Amahsa (1 commits)")

### Embed Badge

![Health badge](/badges/yektadg-laravel-log-activity-mongodb/health.svg)

```
[![Health](https://phpackages.com/badges/yektadg-laravel-log-activity-mongodb/health.svg)](https://phpackages.com/packages/yektadg-laravel-log-activity-mongodb)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B11.5k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1941.5M276](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2328.5M343](/packages/open-telemetry-sdk)

PHPackages © 2026

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