Download the PHP package makidizajnerica/laravel-multiemail without Composer
On this page you can find all versions of the php package makidizajnerica/laravel-multiemail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download makidizajnerica/laravel-multiemail
More information about makidizajnerica/laravel-multiemail
Files in makidizajnerica/laravel-multiemail
Package laravel-multiemail
Short Description Allow users to have more than one email address related to their account.
License MIT
Homepage https://github.com/MakiDizajnerica/laravel-multiemail
Informations about the package laravel-multiemail
Laravel MultiEmail
Allow users to have more than one email address related to their account. Let them set their primary and recovery email addresses.
Installation
As for registering Service Provider, it is not necessary, Laravel will auto load provider using Package Discovery.
Config
Inside config/auth.php
add new provider
like so:
After that you need to edit existing or create new guard
:
Then go down under the passwords
and edit it like so:
The last step would be to change Laravel's default Illuminate\Auth\Passwords\PasswordResetServiceProvider::class
inside config/app.php
like this:
This part is important if you want your users to be able to reset their passwords.
Publishing config
If your User model is not in default namespace you are going to need to publish multiemail.php
config file using:
And then change the model class inside multiemail.php
:
Migrations
First you are going to need to publish migrations using command:
Then run them:
After running the migrations new table emails
will be created.
Please don't forget to remove email
field from users
table!
Usage
Go inside your App\Models\User::class
and add MakiDizajnerica\MultiEmail\HasMultipleEmails::class
trait and implement MakiDizajnerica\MultiEmail\Contracts\HasMultipleEmails::class
:
Then be sure to define emails()
relation method:
After that your User::class
will have some methods available:
And some custom attributes:
Adding new email address
If user does not have primary email defined you can do something like this:
Email verification notification will be sent every time new email is added. If you dont want to send notification you can pass second argument to the addNewEmail()
method like so:
Email types
User may only have one primary and one recovery email address, so it is recommended to use already defined methods for changing types of email addresses:
Email address cannot be primary and recovery at the same time!
Password resets
Defaut email address for password resets will be user's primary email. But if there is recovery email defined, user will be able to use that email address also. Laravel's default password reset service will still be usable as normal, to learn more about password resets visit https://laravel.com/docs/8.x/passwords.
Inside multiemail.php
config file you will be able to enable/disable password resets and to specify if primary email should be used for those resets.
Author
Nemanja Marijanovic ([email protected])
Licence
Copyright © 2021, Nemanja Marijanovic [email protected]
All rights reserved.
For the full copyright and license information, please view the LICENSE file that was distributed within the source root of this package.