offload-project/laravel-invite-only 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version on Packagist GitHub Tests Action Status Total Downloads

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

  • 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

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.

Security

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 offload-project/laravel-invite-only 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 72
  • 点击次数: 29
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 72
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-28