francescoprisco/nova-mongodb
MongoDB integration for Laravel Nova: browse and manage MongoDB collections through Nova resources, with support for fields, filters, and searching backed by the official MongoDB Laravel package.
Install the package and its driver dependency:
composer require francescoprisco/nova-mongodb
php artisan vendor:publish --tag=nova-mongodb-config # check actual tag in README
You need the mongodb PHP extension and mongodb/laravel-mongodb ^5.5 already working before this package is useful.
Confirm the baseline stack before debugging anything else: PHP 8.2+, Laravel 11/12, Nova 5+, MongoDB 5+. A version mismatch here is the most common cause of "observer not firing" or "resource 500s".
Where to look first in the package source:
src/MongoDBResource.php — the base class you will extend for every Nova resource backed by MongoDB.src/Connections/MongoDBConnection.php — only relevant if you use transactions.src/Models/ and src/Traits/ — ActionEvent, NovaNotification, MongoNotifiable, HandlesMorphRelations.routes/ (or wherever the notification routes are registered) — these are custom Nova API routes, not Nova's built-in notification endpoints.First use case: take one existing SQL-backed Nova Resource, change it to extend MongoDBResource, point its model at a MongoDB connection, and open the index view. Then create/update/delete a record and inspect the action_events collection to confirm the ModelObserver is logging. This single loop validates resource rendering, connection wiring, and observer registration in one go.
For notifications, add the MongoNotifiable trait to your User model and hit GET /nova-api/nova-notifications while authenticated. If that returns JSON, the route registration and notification model are wired correctly.
Resources
MongoDBResource rather than NovaResource for any resource backed by MongoDB. The base class supplies regex-based search, which is the main behavioural difference from stock Nova resources.app/Nova directory; the "zero SQL dependencies" claim applies to the Mongo-backed path, not the whole app.HandlesMorphRelations on models/resources that have polymorphic relations, otherwise morph lookups against ObjectIds tend to resolve to the wrong model or return null.Action events / audit logging
ModelObserver is registered automatically for MongoDB models. This means you generally do not call observe() yourself — just create the model and the CRUD logging happens.ActionEvent directly when building custom audit views; it is a normal MongoDB model, so you can aggregate on it.Notifications
MongoNotifiable on the User model (or whichever authenticatable Nova uses). Without it, the custom notification routes will not resolve the notifiable and you will get empty lists or 404/500s./nova-api/nova-notifications. Treat these as the contract for your frontend/toolbar: GET list, POST {id}/read, POST {id}/unread, POST read-all, DELETE {id}, DELETE (all). If you build a custom notification bell, call these instead of Nova's built-in endpoints.read-all and bulk DELETE over loops of single-item calls when clearing a large inbox — each call is a separate round trip and a separate MongoDB write.Transactions
MongoDBConnection exists to handle nested transactions. Use it if you have service-layer code that opens a transaction and then calls model code that opens another; the custom connection flattens those instead of throwing.mongod will fail at runtime regardless of how good the connection class is. Verify rs.status() before blaming the package.Integration tips
config/database.php as you normally would for mongodb/laravel-mongodb, then let the package's connection class wrap it if you need nested transaction support.ActionEvent and NovaNotification in dedicated collections; mixing them into business collections makes cleanup and retention policies awkward.observe() call in a service provider will produce duplicate ActionEvent rows. Grep your providers for the model name if audit counts look inflated.(, [, *) can produce errors or unexpectedly broad matches. Sanitise search input in your resource if the package does not./nova-api/nova-notifications routes live under Nova's prefix. If you have your own notification routes or a Nova tool that registers similar paths, check php artisan route:list for shadowing. Route caching after install is worth doing once to confirm the routes are actually loaded.mongodb/laravel-mongodb ^5.5 is a hard requirement. An older 4.x driver installed transitively by another package will break the connection class. Run composer why mongodb/laravel-mongodb if transactions or observers misbehave.unread or DELETE endpoints.php artisan about), (3) no withoutEvents()/saveQuietly() call is bypassing the observer, (4) the action_events collection exists and is writable.MongoDBResource for custom search behaviour rather than editing the vendor class; subclass the ModelObserver and register it manually if you need to suppress specific events (e.g. skip logging on bulk imports).composer.json so a transitive update cannot silently break the resource base class.How can I help you explore Laravel packages today?