PHP code example of cleaniquecoders / inviteable

1. Go to this page and download the library: Download cleaniquecoders/inviteable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cleaniquecoders / inviteable example snippets


CleaniqueCoders\Inviteable\InviteableServiceProvider::class,

use CleaniqueCoders\Inviteable\Traits\HasInviteable;

class User extends Authenticatable 
{
	use HasInviteable;
}

use App\User;

Artisan::command('invite', function() {
    // create a user that will invite other person
    $invitor = factory(User::class)->create();
    
    // to invite who
    $to_invite = factory(User::class)->create();
    
    // login using invitor
    auth()->loginUsingId($invitor->id);

    // invite user to a class
    $to_invite->invitations()->create([
        'name'       => 'Live Coding Class',
        'token'      => str_random(64),
        'invited_by' => auth()->user()->id,
        'is_expired' => false,
        'expired_at' => \Carbon\Carbon::now()->addHours(24),
    ]);
})->describe('Inivite the fastest way via cli.');

/**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        '\CleaniqueCoders\Inviteable\Events\InvitationCreated' => [
            '\CleaniqueCoders\Inviteable\Listeners\Invitations\SendInvitationEmail',
        ],
    ];

'inviteable' => \CleaniqueCoders\Inviteable\Http\Middleware\Inviteable::class,

 

return [
    'redirect' => [
        'accepted_token' => 'invitation.index',
        'already_accepted_token' => 'invitation.index',
        'middleware' => 'invitation.access_denied'
    ],
];

$ php artisan migrate