Download the PHP package abstem/invites without Composer
On this page you can find all versions of the php package abstem/invites. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package invites
Invites
Invites provides a way to limit access to your Laravel applications by using invite codes.
Invite Codes:
- Can be available to anyone (great for sharing on social media).
- Can have a limited number of uses or unlimited.
- Can have an expiry date, or never expire.
Installation
You can pull in the package using composer:
Next, register the service provider with Laravel (no need on version 5.5):
And, register the facade:
Finally, migrate the database:
Usage
Generate Invites
Make a single generic invite code with 1 redemption, and no expiry.
Make 5 generic invite codes with 1 redemption each, and no expiry.
Make an invite with 10 redemptions and no expiry.
Make an invite that expires on a specific date.
Make an invite that expires in 14 days.
Redeem Invites
You can redeem an invite by calling the ` method. Providing the invite code and optionally an email address.
If invites is able to redeem the invite code it will increment the number of redemptions by 1, otherwise it will throw an exception.
- ` is thrown if the code does not exist in the database.
- ` is thrown if an expiry date is set and it is in the past.
- ` is thrown if the invite code has already been used the maximum number of times.
All of the above exceptions extend ` so you can catch that exception if your application does not need to do anything specific for the above exceptions.
Check Invites without redeeming them
You can check an invite by calling the method. Providing the invite code and optionally an email address. (It has the same signature as the
method except it will return or
instead of throwing an exception.
Change Error Messages (and translation support)
In order to change the error message returned from invites, we need to publish the language files like so:
The language files will then be in where you can edit the
file, and these messages will be used by invites. You can create support for other languages by creating extra folders with a file in the
directory such as ` where you could place your German translations. Read the localisation docs for more info.
Config - change table name
First publish the package configuration:
In config/invites.php
you will see:
If you change the table name and then run your migrations Invites will then use the new table name.
Console
To remove used and expired invites you can use the cleanup
command: