Skip to content

Pandahisham/laravel-invitable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Inviteable

Installation

First, pull in the package through Composer.

composer require tshafer/laravel-inviteable:1.0.*@dev

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

'providers' => [
    Tshafer\Inviteable\ServiceProvider::class
];

At last you need to publish and run the migration.

php artisan vendor:publish --provider="Tshafer\Inviteable\ServiceProvider" && php artisan migrate

Setup a Model

<?php

namespace App;

use Tshafer\Inviteable\Contracts\Inviteable;
use Tshafer\Inviteable\Traits\Inviteable as InviteableTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements Inviteable
{
    use InviteableTrait;
}

Examples

Generate a new invitation code

Invite::getNewCode([
    'email' => 'test@test.io',
]);

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);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages