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/ */
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',
],
];