zinethq / spark-user-team-email
Add different email for a user on a team for Laravel Spark
Requires
- php: >=5.6.4
- laravel/framework: 5.*
Requires (Dev)
- phpunit/phpunit: ~5.5
This package is not auto-updated.
Last update: 2022-02-01 13:08:45 UTC
README
SparkUserTeamEmail provides a simple way for Laravel Spark to allow users to have a different email address on a team, without changing their user email address.
Use case example
Bob Bobbinson is a user of spark-developer.com
. Bob uses bob@bob.com
to log in, but bob@bob.com
is Bob's personal email and bob.com
is Bob's personal website.
Bob is a member of two teams on spark-developer.com
, a team for his personal work (DevBob
) and one for the company he works for (BigDevelopsLtd
). Bob has been given a work email to use for all things BigDevelopsLtd
related. However, out of the box Bob can only have one email - the one used to sign into the site.
Spark User Team Email allows adding secondary email addresses for a user in the context of a team. In this case Bob can add bob@BigDevelopsLtd.com
as his email for the team BigDevelopsLtd
.
Quick Installation
-
Install the package through Composer.
composer require zinethq/spark-user-team-email:dev-master
-
Add the service provider to your project's
config/app.php
file.ZiNETHQ\SparkUserTeamEmail\SparkUserTeamEmailServiceProvider::class,
-
Publish the configuration, models, and migrations into your project.
php artisan vendor:publish --provider="ZiNETHQ\SparkUserTeamEmail\SparkUserTeamEmailServiceProvider"
-
Migrate your database.
php artisan migrate
-
Add the
HasUserTeamEmail
trait to your user model.... use ZiNETHQ\SparkUserTeamEmail\Traits\HasUserTeamEmail; ... class User ... { ... use HasUserTeamEmail; ... }
-
You may wish to add the email to the pivot information of the
teams()
relationship:public function teams() { return $this->sparkTeams()->withPivot(['email', 'role']); }
-
You may wish to add the team emails of a user to your model JSON, do this with:
protected $appends = [ ... 'teamEmails', ... ];