Download the PHP package albaroody/staging without Composer
On this page you can find all versions of the php package albaroody/staging. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download albaroody/staging
More information about albaroody/staging
Files in albaroody/staging
Package staging
Short Description Allow any Laravel model to be saved as a draft (staged) into a separate system without affecting real database tables.
License MIT
Homepage https://github.com/albaroody/staging
Informations about the package staging
Laravel Staging
Laravel Staging allows you to stage (draft) Eloquent models and their nested relationships into a clean, separate system before committing them permanently to your main database.
- Stage parent models like
Patient,Post,Order, etc. - Stage related models like
Sales,Items,Comments, etc. - Hydrate full Eloquent models from staged data (not just arrays)
- Promote staged data to production tables cleanly
- Keep your main database structure untouched — no intrusive columns added!
Perfect for multi-step forms, draft publishing systems, and modular deferred saving workflows.
Installation
You can install the package via Composer:
You can publish and run the staging migration with
You can publish the config file with:
Usage
-
Add the Stagable trait to your model:
-
Stage a model:
-
Load a staged model:
- Promote a staged model to the database:
HasMany Relationships
The library supports staging hasMany relationships, allowing you to create multiple child records before saving the parent.
Basic Usage
-
Stage multiple children at once:
-
Link staged children to a parent:
-
Find staged children by parent:
- Save staged children when parent is saved:
Automatic Child Saving
You can configure models to automatically save staged children when the parent is created via HTTP request:
-
Define hasMany relationships in your model:
- Create parent via HTTP request with staging IDs in the request:
Note: The automatic child saving works by checking the request for _staging_id and {relationship_name}_staging_ids keys. These keys must be present in the request when creating the parent model.
Get Staged Collection for Display
Get a collection of staged objects for display in forms or tables:
Staging Endpoints (Optional)
You can use the included Route macro to easily add staging endpoints to your controllers:
This will create:
POST /products/stage- Stage a product (in addition to standard resource routes)- All standard resource routes (
GET /products,POST /products, etc.)
Your controller should implement a stage method:
Note: Your Product model must use the Stagable trait for the stage() method to be available.
Storing References to Staged Models
You can store references to staged models in your attributes (useful for belongsTo relationships):
Features
✅ Stage any Eloquent model as a draft
✅ Stage multiple children at once with stageMany()
✅ Link staged children to staged parents
✅ Automatic saving of hasMany children when parent is created
✅ Preserve sort order for staged items
✅ Get staged collections for display (model-like objects)
✅ Clean promotion to production tables
✅ No intrusive columns in your main tables
Enjoy easy staging without cluttering your main table with extra columns!
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Albaroody
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of staging with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0