mattyeend/guest-to-user-helper
最新稳定版本:v1.1.5
Composer 安装命令:
composer require mattyeend/guest-to-user-helper
包简介
Guest-to-user migration helper for Laravel.
README 文档
README
Features
- Works with Laravel 10, 11 & 12
- Assigns a unique guest identifier
- Seamlessly migrates guest-owned models to a real user on registration/login
- Simple API, no deep integration needed
Install
composer require MattYeend/guest-to-user-helper php artisan vendor:publish --tag=config php artisan vendor:publish --tag=migrations
Middleware Registration
Laravel 10 and 11
// app/Http/Kernel.php protected $middlewareGroups = [ 'web' => [ \MattYeend\GuestToUserHelper\Http\Middleware\AssignGuestIdentifier::class, ], ];
Laravel 12
// bootstrap/app.php use MattYeend\GuestToUserHelper\Http\Middleware\AssignGuestIdentifier; use Illuminate\Foundation\Configuration\Middleware; return Application::configure(basePath: dirname(__DIR__)) ->withMiddleware(function (Middleware $middleware) { $middleware->group('web', [ AssignGuestIdentifier::class, ]); }) ->create();
Usage
Add HasGuestOwnership to any model you want to track for guests:
use MattYeend\GuestToUserHelper\Traits\HasGuestOwnership; class Cart extends Model { use HasGuestOwnership; }
Migrate data after login/registration:
app(\MattYeend\GuestToUserHelper\GuestMigrator::class)->migrate(auth()->id());
Events available:
GuestMigratingGuestMigrated
Testing
Run the included tests:
vendor/bin/phpunit
License
This package is licensed under the MIT License.
Contributing
Feel free to fork the repository and submit pull requests for improvements or new features!
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-14