Download the PHP package service-to/uses-detail without Composer
On this page you can find all versions of the php package service-to/uses-detail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download service-to/uses-detail
More information about service-to/uses-detail
Files in service-to/uses-detail
Package uses-detail
Short Description A Laravel trait for handling dynamic model attributes using a JSON detail column
License MIT
Informations about the package uses-detail
UsesDetail
A Laravel trait that enables dynamic model attributes using a JSON detail column.
Installation
You can install the package via composer:
Usage
-
Add the
detailcolumn to your migration: - Use the trait in your model:
Features
- Smart Column Detection: Automatically detects whether columns exist in the database schema or JSON detail column
- Unified Query Interface: Use standard Laravel query methods (
where,whereIn,whereNull, etc.) for both schema and detail columns - Performance Optimized: Schema information is cached for 5 minutes to minimize database lookups
- Automatic UUID Generation: Generates UUIDs for models automatically
- Flexible Data Merging: Merge objects or JSON strings into models
- Fully Backward Compatible: Existing
detail()scope continues to work
Querying Data
Using Standard Laravel Query Methods (Recommended)
The package intelligently routes queries to either schema columns or the JSON detail column:
Using the detail() Scope (Backward Compatible)
The original detail() scope method still works:
Note: Both methods now use the same intelligent routing under the hood.
How It Works
When you save a model, the trait automatically:
- Checks which attributes exist in the database schema
- Stores schema columns normally
- Stores non-schema columns in the JSON
detailcolumn - Caches the schema information for 5 minutes
When you query, the custom query builder:
- Checks the cached schema
- Routes queries to regular columns if they exist in the schema
- Routes queries to JSON paths (
detail->column) if they don't exist in the schema
Methods
merge($obj)
Merge an object, array, or JSON string into the model:
find($id)
Enhanced find method with automatic UUID lookup:
License
The MIT License (MIT). Please see License File for more information.
All versions of uses-detail with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0