PHPackages                             mateusjunges/laravel-invite-codes - 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. mateusjunges/laravel-invite-codes

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

mateusjunges/laravel-invite-codes
=================================

This package allows you to easily manage invite codes for your Laravel application.

v2.3.0(8mo ago)29166.8k↓20.5%14[1 PRs](https://github.com/mateusjunges/laravel-invite-codes/pulls)MITPHPPHP ^8.4CI passing

Since Feb 15Pushed 8mo ago5 watchersCompare

[ Source](https://github.com/mateusjunges/laravel-invite-codes)[ Packagist](https://packagist.org/packages/mateusjunges/laravel-invite-codes)[ GitHub Sponsors](https://github.com/mateusjunges)[ RSS](/packages/mateusjunges-laravel-invite-codes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (18)Used By (0)

Laravel Invite Codes
====================

[](#laravel-invite-codes)

[![Readme banner](art/banner.png)](art/banner.png)This package allows you to easily manage invite codes for your Laravel application.

[![Total Downloads](https://camo.githubusercontent.com/c8d9fe0671ec5ecf2fbbdbb3b568d6636e5c8d617e5c7f7d77e39126c4de5dec/68747470733a2f2f706f7365722e707567782e6f72672f6d61746575736a756e6765732f6c61726176656c2d696e766974652d636f6465732f642f746f74616c2e737667)](https://packagist.org/packages/mateusjunges/laravel-invite-codes)[![Latest Stable Version](https://camo.githubusercontent.com/3ef9a02170328f5031da129f3284bf450bce17c2cab1932911aed5de296f1e62/68747470733a2f2f706f7365722e707567782e6f72672f6d61746575736a756e6765732f6c61726176656c2d696e766974652d636f6465732f762f737461626c652e737667)](https://packagist.org/packages/mateusjunges/laravel-invite-codes)[![License](https://camo.githubusercontent.com/49272adabbe15ddecb31cd022560fde24651cdc5753a30287d23b414283c0741/68747470733a2f2f706f7365722e707567782e6f72672f6d61746575736a756e6765732f6c61726176656c2d696e766974652d636f6465732f6c6963656e73652e737667)](https://packagist.org/packages/mateusjunges/laravel-invite-codes)[![Continuous integration](https://github.com/mateusjunges/laravel-invite-codes/workflows/Continuous%20Integration/badge.svg)](https://github.com/mateusjunges/laravel-invite-codes/actions?query=workflow%3A%22Continuous+Integration%22)

Sponsor my work!
================

[](#sponsor-my-work)

If you think this package helped you in any way, you can sponsor me on GitHub!

[![Sponsor Me](art/sponsor.png)](https://github.com/sponsors/mateusjunges)

Documentation
=============

[](#documentation)

- [Installation](#installation)
- [Usage](#usage)
    - [Creating invite codes](#creating-invite-codes)
        - [Set the expiration date of your invite code](#set-the-expiration-date-of-your-invite-code)
        - [Restrict usage to some specific user](#restrict-usage-to-some-specific-user)
        - [Set the maximum allowed usages for an invite code](#set-the-maximum-allowed-usages-for-an-invite-code)
    - [Create multiple invite codes](#create-multiple-invite-codes)
    - [Redeeming invite codes](#redeeming-invite-codes)
    - [Redeeming invite codes without dispatching events](#redeeming-invite-codes-without-dispatching-events)
- [Customizing how invite codes are generated](#customizing-how-invite-codes-are-generated)
- [Extending the `Invite` model](#extending-the-invite-model)
- [Handling invite codes exceptions](#handling-invite-codes-exceptions)
- [Using artisan commands](#using-artisan-commands)
- [Tests](#tests)
- [Contributing](#contributing)
- [Changelog](#changelog)
- [License](#license)

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

[](#installation)

To get started with Laravel Invite Codes, use Composer to add the package to your project's dependencies:

```
composer require mateusjunges/laravel-invite-codes
```

Or add this line in your composer.json, inside the `require` section:

```
{
    "require": {
        "mateusjunges/laravel-invite-codes": "^2.3",
    }
}
```

then run `composer install`.

All migrations required for this package are already included. If you need to customize the tables, you can [publish them](https://github.com/mateusjunges/laravel-invite-codes/tree/master/database/migrations) with:

```
php artisan vendor:publish --provider="Junges\InviteCodes\InviteCodesServiceProvider" --tag="invite-codes-migrations"
```

and set the config for `custom_migrations` to `true`, which is `false` by default.

```
'custom_migrations' => true,
```

After the migrations have been published you can create the tables on your database by running the migrations:

```
php artisan migrate
```

If you change the table names on migrations, please publish the config file and update the tables array. You can publish the config file with:

```
php artisan vendor:publish --provider="Junges\InviteCodes\InviteCodesServiceProvider" --tag="invite-codes-config"
```

When published, the `config/invite-codes.php` config file contains:

```
