PHPackages                             mathewparet/laravelinvites - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mathewparet/laravelinvites

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mathewparet/laravelinvites
==========================

:description

v1.0.0(7y ago)09[1 issues](https://github.com/mathewparet/laravel-invites/issues)MITPHP

Since Jan 25Pushed 7y ago2 watchersCompare

[ Source](https://github.com/mathewparet/laravel-invites)[ Packagist](https://packagist.org/packages/mathewparet/laravelinvites)[ Docs](https://github.com/mathewparet/laravel-invites)[ RSS](/packages/mathewparet-laravelinvites/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (3)Used By (0)

mathewparet/LaravelInvites
==========================

[](#mathewparetlaravelinvites)

A Laravel package that helps manage invitation based user registration.

Project Status
--------------

[](#project-status)

### master

[](#master)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1bd8ba6075547336509acdff6f1ecc4a66e9bea40df5581d1731941ee98c7e21/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617468657770617265742f6c61726176656c2d696e76697465732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mathewparet/laravel-invites/?branch=master)[![Build Status](https://camo.githubusercontent.com/06f3fad8f914a8cd0ab29f2dd61ea19904c0aa1be908934963630d90a889259a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617468657770617265742f6c61726176656c2d696e76697465732f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mathewparet/laravel-invites/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/08f04546ab3d05ca7cfc65360d06befefd9c8b002ce846e78c5f8f13f77dc399/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617468657770617265742f6c61726176656c2d696e76697465732f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)

### develop

[](#develop)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1bb571a9ce0e71327c1a6a4a85590016174bfcb466725cf9ae8ba8a546aedc1d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617468657770617265742f6c61726176656c2d696e76697465732f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/mathewparet/laravel-invites/?branch=develop)[![Build Status](https://camo.githubusercontent.com/210ea2bbdbe25f55a1301dc25acac376e3c65afd604ca6c68a9f4e87a3ab0374/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617468657770617265742f6c61726176656c2d696e76697465732f6261646765732f6275696c642e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/mathewparet/laravel-invites/build-status/develop)[![Code Intelligence Status](https://camo.githubusercontent.com/3e7e43cfcf508f99d02397739501f0e901f975a90d620fb569af4641168fbebd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617468657770617265742f6c61726176656c2d696e76697465732f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d646576656c6f70)](https://scrutinizer-ci.com/code-intelligence)

Introduction
------------

[](#introduction)

This package generates invitation codes for you to use along with registration form.

Invitation codes can

- be tied to an email address.
- be available for multiple uses (got to post on FB!).
- have defined limit for the number of times it can be used.
- can have an expiry date or never.
- can have a future activation date (before which the code cannot be used).

Installation
------------

[](#installation)

You can install the package using [composer](https://getcomposer.org/).

```
composer require mathewparet/laravelinvites
```

For Laravel 5.5 or before, you will need to add:

```
// config/app.php
'providers' => [
    ...
    mathewparet\LaravelInvites\LaravelInvitesServiceProvider::class,
];
```

For ease of use you can define an alias too:

```
// config/app.php
'aliases' => [
    ...
    'LaravelInvites' => mathewparet\LaravelInvites\Facades\LaravelInvites::class
];
```

Finally run the migration:

```
php artisan migrate
```

Publish Configuration
---------------------

[](#publish-configuration)

You may want to publish the configuration files if you want to customize it, or if you want to change the name of the table that will be created to store the invites.

```
php artisan vendor:publish --provider="\mathewparet\LaravelInvites\LaravelInvitesServiceProvider" --tag=config
```

This will copy the configuration file (`config/laravelinvites.php`) to your config directory.

The default table name is `invites`. If you wish to change it, you can change it in the above configuraion file before running the migration.

Usage
=====

[](#usage)

Generate a single onetime use invitation code
---------------------------------------------

[](#generate-a-single-onetime-use-invitation-code)

```
LaravelInvites::generate();
```

Generate multiple onetime use invitation code
---------------------------------------------

[](#generate-multiple-onetime-use-invitation-code)

```
LaravelInvites::generate(10); // generates 10 different invitation codes
```

Generate a multi use invitation code
------------------------------------

[](#generate-a-multi-use-invitation-code)

```
LaravelInvites::allow(25)->generate(); // generates a single code that can be used 25 times
```

Override expiry date defined in the config making a non-expiry code
-------------------------------------------------------------------

[](#override-expiry-date-defined-in-the-config-making-a-non-expiry-code)

```
LaravelInvites::withoutExpiry()->generate();
```

*If you always plan to use invitation codes that never expire then you can make changes in the configuration file. If the `config('laravelinvites.expiry.type')` = `"never"` then you don't need to use `withoutExpiry()` explicitly.*

Override expiry date defined in the config with a specific expiry date
----------------------------------------------------------------------

[](#override-expiry-date-defined-in-the-config-with-a-specific-expiry-date)

```
$date = Carbon\Carbon::now()->addDays(5);
LaravelInvites::setExpiry($date)->generate();
// generates an invitation code that expires in 5 days
```

Set an active / start date
--------------------------

[](#set-an-active--start-date)

```
$date = Carbon\Carbon::now()->addDays(5);
LaravelInvites::notBefore($date)->generate();
// generates an invitation code that can be used only after 5 days
```

OR

```
$date = Carbon\Carbon::now()->addDays(5);
LaravelInvites::validFrom($date)->generate();
// generates an invitation code that can be used only after 5 days
```

Generate an email ID specific invitation code
---------------------------------------------

[](#generate-an-email-id-specific-invitation-code)

```
LaravelInvites::for('john.doe@example.com')->generate();
// This code can be used only by john.doe@example.com
```

OR

```
LaravelInvites::generateFor('john.doe@example.com');
```

Check whether an invitation code is valid
-----------------------------------------

[](#check-whether-an-invitation-code-is-valid)

```
LaravelInvites::isValid($code);
```

OR

```
LaravelInvites::isValid($code, $email);
```

> This method returns `true` or `false`.

> If an invitation code tied to a sepcific email is checked without the correct email ID, it would return false.

> If invitation code is not tied to an email ID, and the invitation code is active and correct, this method will return true whether email ID is null not.

Check validity of invitation code with exceptions
-------------------------------------------------

[](#check-validity-of-invitation-code-with-exceptions)

```
LaravelInvites::check($code, $email);
```

OR

```
LaravelInvites::check($code);
```

> This works just like `isValid()` but instead it throws an exception if validation fails.

Redeem invitation code
----------------------

[](#redeem-invitation-code)

```
LaravelInvites::redeem($code, $email);
```

OR

```
LaravelInvites::redeem($code);
```

> `isValid()` should be called before invoking this since it will throw an exception if invitation code is invalid.

Get list of invitation codes
----------------------------

[](#get-list-of-invitation-codes)

```
LaravelInvites::get();
```

OR

```
LaravelInvites::for('john.doe@example.com')->get();
```

Form request validation
-----------------------

[](#form-request-validation)

To validate an invitation code submitted via form:

```
public function store(Request $request)
{
    $request->validate([
        'email' => 'required|email|unique:users',
        'code' => 'required|valid_code:email', // here email is the field that holds the email id
    ]);

    // Add the user to the database.
}
```

Console
=======

[](#console)

The below console commands are available.

```
php artisan invites:generate
```

```
php artisan invites:cleanup
```

```
php artisan invites:check
```

Email with Invitation Code
==========================

[](#email-with-invitation-code)

When invitation code is generated for a specific email ID (using `php artisan invites:generate` or using the Facade), an invitation mail will be automatically sent to the email ID.

You can disable, customize this in the configuraiton file.

If it is enabled, then when a user clicks on the invitation link, his email ID and invitation code will be automatically filled in your registration form. It will work out of the box if you use the built in registration form that comes with Laravel. Else you can customize the route name for the registration form under `routes.register`. You can customize `email` and `code` fields names as in your registration form so that it can be auto populated.

You can publish the mail mail markdown if you wish to customize it:

```
php artisan vendor:publish --provider="mathewparet\LaravelInvites\LaravelInvitesServiceProvider" --tag=mail
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 93.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2665d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2384106?v=4)[Mathew Paret](/maintainers/mathewparet)[@mathewparet](https://github.com/mathewparet)

---

Top Contributors

[![mathewparet](https://avatars.githubusercontent.com/u/2384106?v=4)](https://github.com/mathewparet "mathewparet (41 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (3 commits)")

---

Tags

laravelLaravelInvites

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mathewparet-laravelinvites/health.svg)

```
[![Health](https://phpackages.com/badges/mathewparet-laravelinvites/health.svg)](https://phpackages.com/packages/mathewparet-laravelinvites)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
