offload-project/laravel-invite-only
Composer 安装命令:
composer require offload-project/laravel-invite-only
包简介
A Laravel package for managing user invitations with polymorphic relationships, token-based access, scheduled reminders, and event-driven notifications.
关键字:
README 文档
README
Laravel Invite Only
A Laravel package for managing user invitations with polymorphic relationships, token-based access, scheduled reminders, and event-driven notifications.
Features
- Polymorphic invitations - Invite users to any model (teams, organizations, projects)
- Bulk invitations - Invite multiple users at once with partial failure handling
- Token-based secure links - Shareable invitation URLs with secure tokens
- Status tracking - Pending, accepted, declined, expired, and cancelled states
- Automatic reminders - Scheduled reminder emails for pending invitations
- Event-driven - Events fired for all invitation lifecycle changes
- Translatable notifications - All notification messages customizable via language files
- Structured exceptions - Error codes and resolution hints for easy debugging
Table of Contents
- Requirements
- Installation
- Quick Start
- Full Documentation
- AI Coding Assistant Skill
- Testing
- Contributing
- License
Requirements
- PHP 8.2+
- Laravel 11/12/13
Installation
composer require offload-project/laravel-invite-only php artisan vendor:publish --tag="invite-only-config" php artisan vendor:publish --tag="invite-only-migrations" php artisan migrate
Quick Start
1. Add Traits
// Team.php (or any model that can have invitations) use OffloadProject\InviteOnly\Traits\HasInvitations; class Team extends Model { use HasInvitations; }
// User.php use OffloadProject\InviteOnly\Traits\CanBeInvited; class User extends Authenticatable { use CanBeInvited; }
If a model both sends and receives invitations (e.g. user-to-user friend
invitations), apply both traits. The two traits each define an
acceptedInvitations() method, so use PHP's trait conflict resolution:
use OffloadProject\InviteOnly\Traits\CanBeInvited; use OffloadProject\InviteOnly\Traits\HasInvitations; class User extends Authenticatable { use HasInvitations, CanBeInvited { CanBeInvited::acceptedInvitations insteadof HasInvitations; HasInvitations::acceptedInvitations as acceptedInvitationsToModel; } }
In v3.0 the HasInvitations::acceptedInvitations() helper will be removed in
favour of getAcceptedInvitations(), eliminating the conflict — at which point
the insteadof/as clauses can be dropped.
2. Send Invitations
// Single invitation $team->invite('user@example.com', [ 'role' => 'member', 'invited_by' => auth()->user(), ]); // Bulk invitations $result = $team->inviteMany( ['one@example.com', 'two@example.com', 'three@example.com'], ['role' => 'member', 'invited_by' => auth()->user()] ); $result->successful; // Collection of created invitations $result->failed; // Collection of failures with reasons
3. Handle Acceptance
use OffloadProject\InviteOnly\Events\InvitationAccepted; Event::listen(InvitationAccepted::class, function ($event) { $team = $event->invitation->invitable; $user = $event->user; $role = $event->invitation->role; $team->users()->attach($user->id, ['role' => $role]); });
4. Schedule Reminders (Optional)
// routes/console.php Schedule::command('invite-only:send-reminders --mark-expired')->daily();
Full Documentation
- Getting Started - Step-by-step tutorial
- API Reference - All methods, events, and configuration
- Concepts - Lifecycle, architecture, and design decisions
How-To Guides
AI Coding Assistant Skill
This package ships a Laravel Boost skill so coding assistants (Claude Code, Cursor, etc.) follow the package's conventions when generating code. Install it in your app with:
php artisan boost:add-skill offload-project/laravel-invite-only
The skill source lives at skills/SKILL.md.
Testing
composer test
Contributing
Contributions are welcome! Please see the documents below before getting started.
- Contributing Guide — setup, workflow, commit conventions, and PR process
- Code of Conduct — expectations for participation in this project
Security
- Security Policy — how to report a vulnerability privately
License
The MIT License (MIT). Please see License File for more information.
offload-project/laravel-invite-only 适用场景与选型建议
offload-project/laravel-invite-only 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.38k 次下载、GitHub Stars 达 72, 最近一次更新时间为 2025 年 12 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「notifications」 「laravel」 「polymorphic」 「user-management」 「Invite」 「Invitation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 offload-project/laravel-invite-only 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 offload-project/laravel-invite-only 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 offload-project/laravel-invite-only 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova package that adds a notification feed in your Nova app.
Laravel Ownership simplify management of Eloquent model's owner.
Implement a polymorphic morphMany relationship for managing attachments within Filament
A Laravel package providing a full-featured, framework-agnostic commenting system for any Eloquent model.
Metamel Addresses is a polymorphic Laravel package, for address book management. You can add addresses to any eloquent model with ease.
Captures outgoing SMS notifications
统计信息
- 总下载量: 8.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 72
- 点击次数: 29
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-28