PHPackages                             francescoprisco/nova-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. [Database &amp; ORM](/categories/database)
4. /
5. francescoprisco/nova-mongodb

ActiveLibrary[Database &amp; ORM](/categories/database)

francescoprisco/nova-mongodb
============================

Complete Laravel Nova adapter for MongoDB - enables full Nova functionality on MongoDB databases without SQL dependencies

1.0.0(5mo ago)10MITPHPPHP ^8.2

Since Jan 19Pushed 5mo agoCompare

[ Source](https://github.com/francescoprisco/nova-mongodb)[ Packagist](https://packagist.org/packages/francescoprisco/nova-mongodb)[ Docs](https://github.com/francescoprisco/nova-mongodb)[ RSS](/packages/francescoprisco-nova-mongodb/feed)WikiDiscussions main Synced today

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

Laravel Nova MongoDB Adapter
============================

[](#laravel-nova-mongodb-adapter)

Complete package to integrate Laravel Nova with MongoDB, enabling all Nova features on MongoDB databases without any SQL dependencies.

✨ Features
----------

[](#-features)

- ✅ **Nova Resources**: Complete CRUD on MongoDB collections
- ✅ **Full-Text Search**: Case-insensitive regex search on MongoDB
- ✅ **Action Events**: Complete action logging system via Observer pattern
- ✅ **Authentication**: User model fully on MongoDB
- ✅ **Notifications**: Complete notification system with mark read/unread on MongoDB
- ✅ **Transaction Handling**: Automatic nested transaction management
- ✅ **Zero SQL**: No SQL database dependencies

📦 Installation
--------------

[](#-installation)

```
composer require francescoprisco/nova-mongodb
```

The service provider is automatically registered via Laravel package auto-discovery.

### MongoDB Configuration

[](#mongodb-configuration)

Make sure you have MongoDB connection configured in your `config/database.php`:

```
'connections' => [
    'mongodb' => [
        'driver' => 'mongodb',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', 27017),
        'database' => env('DB_DATABASE', 'database'),
        'username' => env('DB_USERNAME', ''),
        'password' => env('DB_PASSWORD', ''),
        'options' => [
            'database' => env('DB_AUTHENTICATION_DATABASE', 'admin'),
        ],
    ],
],

## ⚙️ Configuration

### 1. User Model

```php
use MongoDB\Laravel\Auth\User as Authenticatable;
use FrancescoPrisco\NovaMongoDB\Traits\MongoNotifiable;

class User extends Authenticatable
{
    use MongoNotifiable;

    protected $connection = 'mongodb';
    protected $collection = 'users';

    protected $fillable = ['name', 'email', 'password'];
}
```

### 2. Nova Resources

[](#2-nova-resources)

Resources must extend `MongoDBResource`:

```
use FrancescoPrisco\NovaMongoDB\MongoDBResource;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\Select;

class Bookings extends MongoDBResource
{
    public static $model = \App\Models\Bookings::class;
    public static $title = 'customer_name';
    public static $search = ['id', 'customer_name', 'status'];

    public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),
            Text::make('Customer Name')->sortable(),
            DateTime::make('Booking Date')->sortable(),
            Select::make('Status')->options([
                'pending' => 'Pending',
                'confirmed' => 'Confirmed',
                'cancelled' => 'Cancelled',
            ]),
            Text::make('Notes')->hideFromIndex(),
        ];
    }
}
```

### 3. MongoDB Models

[](#3-mongodb-models)

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

class Bookings extends Model
{
    protected $connection = 'mongodb';
    protected $collection = 'bookings';

    protected $fillable = [
        'customer_name',
        'booking_date',
        'status',
        'notes',
    ];

    protected $casts = [
        'booking_date' => 'datetime',
    ];
}
```

🏗️ Architecture
---------------

[](#️-architecture)

### Main Components

[](#main-components)

#### `MongoDBResource`

[](#mongodbresource)

Base class for Nova resources with complete MongoDB support:

- Case-insensitive regex search via MongoDB (`$regex`)
- Correct type hints for MongoDB builder
- Compatibility with all Nova CRUD operations

#### `MongoDBConnection`

[](#mongodbconnection)

Extends standard MongoDB connection to handle nested transactions:

- Automatically catches errors from transactions already in progress
- Executes callbacks directly when necessary
- Prevents "Transaction already in progress" errors

#### `ModelObserver`

[](#modelobserver)

Automatic observer for action logging:

- Automatically registered on all MongoDB models
- Logs created, updated, deleted events
- Saves to `action_events` collection with complete change tracking

#### MongoDB Models

[](#mongodb-models)

**ActionEvent**: Saves action events in `action_events` collection with complete details (batch\_id, user\_id, changes, original, status) **NovaNotification**: Notification model in `notifications` collection with read/unread support

#### Traits

[](#traits)

**MongoNotifiable**: Complete notification management with `notifications()` and `unreadNotifications()` relations **HandlesMorphRelations**: Helper for MongoDB polymorphic relations

### Custom Routes

[](#custom-routes)

The package automatically registers custom routes for Nova notifications:

- `GET /nova-api/nova-notifications` - List notifications
- `POST /nova-api/nova-notifications/{id}/read` - Mark as read
- `POST /nova-api/nova-notifications/{id}/unread` - Mark as unread
- `POST /nova-api/nova-notifications/read-all` - Mark all as read
- `DELETE /nova-api/nova-notifications/{id}` - Delete notification
- `DELETE /nova-api/nova-notifications` - Delete all

🚀 Usage
-------

[](#-usage)

### Create a new resource

[](#create-a-new-resource)

```
php artisan nova:resource Product
```

Modify the generated resource:

```
use FrancescoPrisco\NovaMongoDB\MongoDBResource;

class Product extends MongoDBResource
{
    public static $model = \App\Models\Product::class;
    public static $search = ['name', 'sku', 'description'];

    // ... fields and configuration
}
```

### Register the resource

[](#register-the-resource)

In `app/Providers/NovaServiceProvider.php`:

```
use App\Nova\Product;

protected function resources()
{
    Nova::resources([
        Product::class,
        // other resources...
    ]);
}
```

⚠️ Known Limitations
--------------------

[](#️-known-limitations)

### 1. Scout Search

[](#1-scout-search)

Laravel Scout advanced search requires a custom MongoDB driver. Currently search uses native MongoDB regex.

### 2. Advanced Metrics

[](#2-advanced-metrics)

Cards/Metrics using complex SQL aggregations may require rewriting using MongoDB aggregation pipeline.

### 3. Lenses

[](#3-lenses)

Nova Lenses using complex SQL queries may not work directly and require adaptation.

🔧 Troubleshooting
-----------------

[](#-troubleshooting)

### Search not working

[](#search-not-working)

Verify that:

1. The resource extends `MongoDBResource`
2. The `$search` fields are defined
3. The model uses `connection = 'mongodb'`

### User cannot authenticate

[](#user-cannot-authenticate)

Verify:

1. User model extends `MongoDB\Laravel\Auth\User`
2. Uses the `MongoNotifiable` trait
3. `config/auth.php` points to the correct model

📊 Performance
-------------

[](#-performance)

The package automatically optimizes:

- Multiple queries via eager loading
- Automatic indexing of search fields
- Nova-compatible result caching

🛠️ Future Development
---------------------

[](#️-future-development)

Roadmap:

- Resource viewer to display ActionEvents in Nova UI
- Advanced metrics/cards adapter with aggregation pipeline
- Scout driver for MongoDB full-text search
- Support for custom Lenses
- Complete test suite
- MongoDB-native dashboard widgets with real-time updates

📋 Requirements
--------------

[](#-requirements)

- PHP 8.2+
- Laravel 11.0+ or 12.0+
- Laravel Nova 5.0+
- MongoDB 5.0+
- mongodb/laravel-mongodb ^5.5

📄 License
---------

[](#-license)

MIT License - Francesco Prisco

🤝 Support
---------

[](#-support)

For issues and support:

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance70

Regular maintenance activity

Popularity2

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

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

167d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12104930?v=4)[francescoprisco](/maintainers/francescoprisco)[@francescoprisco](https://github.com/francescoprisco)

---

Tags

laraveldatabaseadapternosqlmongodbnova

### Embed Badge

![Health badge](/badges/francescoprisco-nova-mongodb/health.svg)

```
[![Health](https://phpackages.com/badges/francescoprisco-nova-mongodb/health.svg)](https://phpackages.com/packages/francescoprisco-nova-mongodb)
```

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11223.5M33](/packages/anourvalar-eloquent-serialize)[waad/laravel-model-metadata

A robust Laravel package for handling metadata with JSON casting, custom relation names, and advanced querying capabilities.

854.6k](/packages/waad-laravel-model-metadata)[mostafaznv/nova-laracache

LaraCache Tool for Laravel Nova

114.0k](/packages/mostafaznv-nova-laracache)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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