offload-project / laravel-invite-only
A Laravel package for managing user invitations with polymorphic relationships, token-based access, scheduled reminders, and event-driven notifications.
Installs: 268
Dependents: 2
Suggesters: 0
Security: 0
Stars: 3
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/offload-project/laravel-invite-only
Requires
- php: ^8.2
- illuminate/database: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- captainhook/captainhook-phar: ^5.27
- larastan/larastan: ^3.8.1
- laravel/pint: ^1.26.0
- orchestra/testbench: ^9.0|^10.8.0
- pestphp/pest: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
- ramsey/conventional-commits: ^1.6
This package is auto-updated.
Last update: 2026-01-07 23:36:23 UTC
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
- Structured exceptions - Error codes and resolution hints for easy debugging
Requirements
- PHP 8.2+
- Laravel 11.0 or 12.0
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; }
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();
Documentation
- Getting Started - Step-by-step tutorial
- API Reference - All methods, events, and configuration
- Concepts - Lifecycle, architecture, and design decisions
How-To Guides
Testing
composer test
License
MIT License. See LICENSE for details.