1. Go to this page and download the library: Download junaidnasir/larainvite 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/ */
// Get route
$code = Request::input('code');
if( Invite::isValid($code))
{
$invitation = Invite::get($code); //retrieve invitation modal
$invited_email = $invitation->email;
$referral_user = $invitation->user;
// show signup form
} else {
$status = Invite::status($code);
// show error or show simple signup form
}
// Post route
$code = Request::input('code');
$email = Request::input('signup_email');
if( Invite::isAllowed($code,$email) ){
// Register this user
Invite::consume($code);
} else {
// either refCode is inavalid, or provided email was not invited against this refCode
}
use Junaidnasir\Larainvite\Events\Invited;
use App\Listeners\SendUserInvitationNotification;
protected $listen = [
Invited::class => [
SendUserInvitationNotification::class,
],
];
public function handle($invitation)
{
\Mail::queue('invitations.emailBody', $invitation, function ($m) use ($invitation) {
$m->from('From Address', 'Your App Name');
$m->to($invitation->email);
$m->subject("You have been invited by ". $invitation->user->name);
});
}