Download the PHP package mateusjunges/laravel-invite-codes without Composer

On this page you can find all versions of the php package mateusjunges/laravel-invite-codes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-invite-codes

Laravel Invite Codes

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

Total Downloads Latest Stable Version License Continuous integration

Sponsor my work!

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

Documentation

Installation

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

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

then run composer install.

All migrations required for this package are already included. If you need to customize the tables, you can publish them with:

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

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

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:

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

Usage

This package provides a middleware called ProtectedByInviteCodeMiddleware. If you want to use it to protect your routes, you need to register it in your $routeMiddleware array, into app/Http/Kernel.php file:

Now you can protect your routes using middleware rules:

You can also add it to the __construct(), in your controllers:

Note This middleware expects to find an invitation code within the invite_code key of your request.

Creating invite codes

To create a new invite code, you must use the InviteCodes facade. Here is a simple example:

The code above will create a new invite code, which can be used 10 times only by a logged in user who has the specified email [email protected].

The methods you can use with the InviteCodes facade are listed below:

Set the expiration date of your invite code

To set the expiration date of your invite code you can use one of the following methods:

Restrict usage to some specific user:

To restrict the usage of an invite code you can use the restrictUsageTo() method, and pass in the email of the user who will be able to use this invite code.

Set the maximum allowed usages for an invite code:

If you want that your invite code be used a limited amount of times, you can set the max usages limit with the maxUsages() method, and pass an integer with the amount of allowed usages.

Create multiple invite codes

If you want to create more than one invite code with the same configs, you can use the make() method. This method generates the specified amount of invite codes. For example:

The code above will create 10 new invite codes which can be used 10 times each, and will expire in 30 days from now.

Redeeming invite codes

To redeem an invite code, you can use the redeem method:

When any invite is redeemed, the InviteRedeemedEvent will be dispatched.

Redeeming invite codes without dispatching events

If you want to redeem an invite codes without dispatch the InviteRedeemedEvent, you can use the withoutEvents() method:

Customizing how invite codes are generated

By default, this package generates a random 16 characters string that. Sometimes, you may want to customize how your invitation code is generated, for adding a prefix to the invitation code or anything you need.

If you need to customize how your invite codes are generated, you can add a call to the InviteCodes facade createInviteCodesusing method, in your service provider:

From now on, all of your invites will have the THIS-IS-MY-INVITE- prefix.

Also, the package itself will handle duplicate invites, so you don't need to take care of that yourself.

Extending the Invite model

The \Junges\InviteCodes\Models\Invite is fully extendable and replaceable. You can extend or create a new model to be used instead of the default one, and the only thing you need to do is implement the \Junges\InviteCodes\Contracts\InviteContract interface, which contains some required methods for this package to work.

After implementing the contract, you need to change the models.invite_model configuration value in config/invite-codes.php.

Handling invite codes exceptions

If you want to override the default 403 response, you can catch the exceptions using the laravel exception handler:

Using artisan commands

This package also provides a command to delete all expired invites from your database. You can use it like this:

After all expired invites has been deleted, it will dispatch the DeletedExpiredInvitesEvent.

Tests

Run composer test to test this package.

Contributing

Thank you for considering contributing for the Laravel Invite Codes package! The contribution guide can be found here.

Changelog

Please see changelog for more information about the changes on this package.

License

The Laravel Invite Codes package is open-sourced software licenced under the MIT License. Please see the License File for more information.


All versions of laravel-invite-codes with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3
illuminate/auth Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
illuminate/database Version ^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mateusjunges/laravel-invite-codes contains the following files

Loading the files please wait ....