PHP code example of makidizajnerica / laravel-multiemail
1. Go to this page and download the library: Download makidizajnerica/laravel-multiemail 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/ */
makidizajnerica / laravel-multiemail example snippets
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, // <- remove this line
MakiDizajnerica\MultiEmail\Providers\PasswordResetServiceProvider::class, // <- add this line
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
],
'user_model' => \Custom\Namespace\User::class,
namespace App\Models;
use MakiDizajnerica\MultiEmail\HasMultipleEmails;
use Illuminate\Foundation\Auth\User as Authenticatable;
use MakiDizajnerica\MultiEmail\Contracts\HasMultipleEmails as HasMultipleEmailsContract;
class User extends Authenticatable implements HasMultipleEmailsContract
{
use HasMultipleEmails;
//
}
use MakiDizajnerica\MultiEmail\Models\Email;
public function emails() : HasMany
{
return $this->hasMany(Email::class);
}
/**
* Add new email address.
*
* @param array $email
* @param bool $sendVerification
* @return \MakiDizajnerica\MultiEmail\Email
*/
public function addNewEmail(array $email, $sendVerification = true);
/**
* Find email address.
*
* @param mixed $email
* @param string $field
* @return \MakiDizajnerica\MultiEmail\Email|null
*/
public function findMyEmail($email, $field = 'email');
/**
* Determine if user is the owner of the provided email address.
*
* @param string $email
* @return bool
*/
public function isMyEmail($email);
/**
* Remove all user's email addresses.
*
* @return void
*/
public function removeAllEmails();
/**
* Check if the provided email address is verified.
*
* @param string $email
* @return bool
*/
public function isVerifiedEmail($email);
/**
* Determine if provided email address is primary.
*
* @param string $email
* @return bool
*/
public function isPrimaryEmail($email);
/**
* Change primary email address.
*
* @param string $email
* @return void
*/
public function setEmailAsPrimary($email);
/**
* Determine if user has recovery email address.
*
* @return bool
*/
public function hasRecoveryEmail();
/**
* Determine if provided email address is recovery.
*
* @param string $email
* @return bool
*/
public function isRecoveryEmail($email);
/**
* Change recovery email address.
*
* @param string $email
* @return void
*/
public function setEmailAsRecovery($email);
// Get all user's verified emails
$user->verified_emails
// Get primary email
$user->email
// Get recovery email if it exists
$user->recovery_email
use App\Models\User;
$user = User::first();
if ($user->isMyEmail('[email protected]')) {
// Set as primary
$user->setEmailAsPrimary('[email protected]');
// Set as recovery
$user->setEmailAsRecovery('[email protected]');
}