Laravel Invite Only

Laravel Invite Only stats

Downloads
373
Stars
3
Open Issues
0
Forks
0

View on GitHub →

A Laravel package for managing user invitations with polymorphic relationships, token-based access, scheduled reminders, and event-driven notifications.

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
  • 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

How-To Guides

Testing

composer test

License

MIT License. See LICENSE for details.

offload-project photo

We apply cognitive psychology to build custom software that reduces mental overhead. Less friction. More flow. Systems designed for how people actually think.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Offload Project Laravel Invite Only Related Articles

Laravel Invite Only Adds a Full User Invitation System with Tokens, Events, and Reminders image

Laravel Invite Only Adds a Full User Invitation System with Tokens, Events, and Reminders

Read article
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Typesense Search logo

Typesense Search

Typesense is an open source, blazing-fast search engine, optimized for helping you build delightful search experiences for your sites and apps. Natively integrated with Laravel Scout.

Typesense Search
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises