albaroody / staging
Allow any Laravel model to be saved as a draft (staged) into a separate system without affecting real database tables.
Fund package maintenance!
:vendor_name
Requires
- php: ^8.2
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: *
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
- spatie/laravel-ray: ^1.35
README
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:
composer require albaroody/staging
You can publish and run the staging migration with
php artisan vendor:publish --tag="staging-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="staging-config"
Usage
- Add the Stagable trait to your model:
use Albaroody\\Staging\\Traits\\Stagable; class Patient extends Model { use Stagable; }
- Stage a model:
$patient = new Patient([ 'name' => 'John Doe', ]); $patient->stage();
- Load a staged model:
$stagedPatient = Patient::findStaged($stagingId); // Now you can use it like a normal model echo $stagedPatient->name;
- Promote a staged model to the database:
$realPatient = $stagedPatient->promoteFromStaging();
Enjoy easy staging without cluttering your main table with extra columns
Testing
composer test
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
License
The MIT License (MIT). Please see License File for more information.