Download the PHP package kevjo/laravel-collab without Composer
On this page you can find all versions of the php package kevjo/laravel-collab. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kevjo/laravel-collab
More information about kevjo/laravel-collab
Files in kevjo/laravel-collab
Package laravel-collab
Short Description Real-time collaborative editing for Laravel with intelligent locking and conflict resolution.
License MIT
Informations about the package laravel-collab
Laravel Collab
Pessimistic locking for Laravel Eloquent models. Prevent multiple users from editing the same record simultaneously.
Requirements
- PHP 8.5+
- Laravel 12+
- MySQL 8+ or PostgreSQL (required for row-level locking via
lockForUpdate())
Note: SQLite works for development/testing but does not support row-level locking. Race condition protection requires MySQL or PostgreSQL in production.
Installation
Run the install command:
This publishes the config file, migrations, and runs the migrations.
Quick Start
1. Add the Trait to Your Model
2. Acquire and Release Locks
3. Check Lock Status
Middleware
The package provides a collab.lock middleware that returns HTTP 423 (Locked) when a route-bound model is locked by another user.
The middleware:
- Returns 423 Locked with lock info if the model is locked by another user
- Passes through if the model is unlocked or locked by the current user
- Skips the check entirely if no user is authenticated
Configuration
Publish the config:
Lock Options
Lock Management
Facade
The Collab facade provides system-wide lock management:
Events
All events are in the Kevjo\LaravelCollab\Events namespace:
| Event | Fired When | Properties |
|---|---|---|
LockAcquired |
Lock is successfully acquired | $model, $lock, $user |
LockReleased |
Lock is released by owner | $model, $user |
LockForceReleased |
Lock is force-released (admin) | $model, $lockOwner, $releasedBy |
LockRequested |
User requests lock from owner | $model, $requester, $lockOwner |
LockExpired |
Expired lock is cleaned up | $model, $lock |
Listen to events in your EventServiceProvider or with closures:
Artisan Commands
Add to your scheduler for automatic cleanup:
Automatic Behaviors
The trait hooks into Eloquent model events:
- Before update: If
prevent_update_if_lockedistrueand the model is locked by another user, aModelLockedException(HTTP 423) is thrown. - After update: If
auto_release_after_updateistrue, the lock is automatically released. - On delete: All locks on the model are released with history entries created.
Testing
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-collab with dependencies
illuminate/support Version ^12.0
illuminate/database Version ^12.0
illuminate/events Version ^12.0
illuminate/console Version ^12.0