zinethq/spark-user-team-email

This package is abandoned and no longer maintained. The author suggests using the centrality-labs/spark-user-team-email package instead.

Add different email for a user on a team for Laravel Spark

dev-master / 1.0.x-dev 2017-08-09 09:21 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:08:45 UTC


README

Laravel 5.3 Spark 2.0 Source Build Status License

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

  1. Install the package through Composer.

    composer require zinethq/spark-user-team-email:dev-master
  2. Add the service provider to your project's config/app.php file.

    ZiNETHQ\SparkUserTeamEmail\SparkUserTeamEmailServiceProvider::class,
  3. Publish the configuration, models, and migrations into your project.

    php artisan vendor:publish --provider="ZiNETHQ\SparkUserTeamEmail\SparkUserTeamEmailServiceProvider"
  4. Migrate your database.

    php artisan migrate
  5. Add the HasUserTeamEmail trait to your user model.

    ...
    use ZiNETHQ\SparkUserTeamEmail\Traits\HasUserTeamEmail;
    ...
    
    class User ... {
        ...
        use HasUserTeamEmail;
        ...
    }
  6. You may wish to add the email to the pivot information of the teams() relationship:

        public function teams()
        {
            return $this->sparkTeams()->withPivot(['email', 'role']);
        }
  7. You may wish to add the team emails of a user to your model JSON, do this with:

    protected $appends = [
        ...
        'teamEmails',
        ...
    ];