Skip to content

forked-repo/Laravel-Inviteable

Repository files navigation

Laravel Inviteable

Installation

Require this package, with Composer, in the root directory of your project.

$ composer require faustbrian/laravel-inviteable

And then include the service provider within app/config/app.php.

BrianFaust\Inviteable\InviteableServiceProvider::class

To get started, you'll need to publish the vendor assets and migrate:

php artisan vendor:publish --provider="BrianFaust\Inviteable\InviteableServiceProvider" && php artisan migrate

Usage

Setup a Model

<?php

namespace App;

use BrianFaust\Inviteable\HasInvitesTrait;
use BrianFaust\Inviteable\Interfaces\HasInvites;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements HasInvites
{
    use HasInvitesTrait;
}

Examples

Generate a new invitation code

Invite::getNewCode([
    'email' => '[email protected]',
]);

Find an invitation by code

Invite::getInviteByCode($invite->code);

Find a valid invitation by code

Invite::getValidInviteByCode($invite->code);

Claim an invitation

$invite->claim($user);

Check if an invitiation has already been claimed

if ($invite->claimed()) {
    dd('This invite has already been claimed.');
}

Access the model that claimed the invite

dump($invite->claimer);

Access the invite that has been claimed by a model

dump($user->invite);

Security

If you discover a security vulnerability within this package, please send an e-mail to Brian Faust at [email protected]. All security vulnerabilities will be promptly addressed.

License

MIT © Brian Faust

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages