Download the PHP package jeremy379/laravel-disconnectable without Composer
On this page you can find all versions of the php package jeremy379/laravel-disconnectable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download jeremy379/laravel-disconnectable
More information about jeremy379/laravel-disconnectable
Files in jeremy379/laravel-disconnectable
Download jeremy379/laravel-disconnectable
More information about jeremy379/laravel-disconnectable
Files in jeremy379/laravel-disconnectable
Vendor jeremy379
Package laravel-disconnectable
Short Description Laravel Eloquent trait to disconnect models from the database at runtime
License MIT
Package laravel-disconnectable
Short Description Laravel Eloquent trait to disconnect models from the database at runtime
License MIT
Please rate this library. Is it a good library?
Informations about the package laravel-disconnectable
Eloquent Disconnectable
Disconnect Laravel Eloquent models from their database connection at runtime.
Why this package?
In many applications following Clean Architecture or Hexagonal Architecture, you want to:
- Prevent database connections from leaking into the Domain or Application layers.
- Ensure models returned from the infrastructure layer are read-only and safe to use.
- Avoid accidental lazy-loading or persisting in views, services, or domain objects.
eloquent-disconnectable provides a simple way to “cut” the database connection of a model or collection before returning it from repositories or infrastructure services, while keeping the original model attributes and already loaded relations accessible.
Benefits
- ✅ Prevents lazy-loading of relations.
- ✅ Prevents persistence operations (
save,delete,push) on disconnected models. - ✅ Keeps already loaded relations accessible.
- ✅ Helps enforce Clean Architecture principles by isolating the domain from database concerns.
Installation
Require via Composer:
Usage
In a Model
Disconnect a single model
Why and where to use it
- Infrastructure layer / repository: disconnect models before returning them to the Domain layer.
- Domain layer / services / controllers: ensures models are read-only and cannot accidentally hit the database.
- View / API layer: safe to render attributes and loaded relations without DB risk.
Clean Architecture Enforcement
By disconnecting Eloquent models:
- Domain layer never touches the DB.
- Models are pure data objects for business logic.
- Already loaded relations are preserved, so performance stays optimal.
License
MIT © Jérémy Dillenbourg
All versions of laravel-disconnectable with dependencies
PHP Build Version
Package Version
The package jeremy379/laravel-disconnectable contains the following files
Loading the files please wait ...