public function inviteUserByEmail($email)
    {
        $model = config('auth.model');

        $invitedUser = (new $model)->where('email', $email)->first();

        $invitation = $this->invitations()
                ->where('email', $email)->first();

        if (! $invitation) {
            $invitation = $this->invitations()->create([
                'user_id' => $invitedUser ? $invitedUser->id : null,
                'email' => $email,
                'token' => str_random(40),
            ]);
        }

        $email = $invitation->user_id
                        ? 'spark::emails.team.invitations.existing'
                        : 'spark::emails.team.invitations.new';

        Mail::send($email, compact('invitation'), function ($m) use ($invitation) {
            $m->to($invitation->email)->subject('New Invitation!');
        });

        return $invitation;
    }
public function inviteUserByEmail($email)
    {
        $model = config('auth.model');

        $invitedUser = (new $model)->where('email', $email)->first();

        $invitation = $this->invitations()
                ->where('email', $email)->first();

        if (! $invitation) {
            $invitation = $this->invitations()->create([
                'user_id' => $invitedUser ? $invitedUser->id : null,
                'email' => $email,
                'token' => str_random(40),
            ]);
        }

        $email = $invitation->user_id
                        ? 'spark::emails.team.invitations.existing'
                        : 'spark::emails.team.invitations.new';

        Mail::send($email, compact('invitation'), function ($m) use ($invitation) {
            $m->to($invitation->email)->subject('New Invitation!');
        });

        return $invitation;
    }
public function inviteUserByEmail ( $ email ) { $ model = config ( 'auth.model' ) ; $ invitedUser = ( new $ model ) -> where ( 'email' , $ email ) -> first ( ) ; $ invitation = $ this -> invitations ( ) -> where ( 'email' , $ email ) -> first ( ) ; if ( ! $ invitation ) { $ invitation = $ this -> invitations ( ) -> create ( [ 'user_id' => $ invitedUser ? $ invitedUser -> id : null , 'email' => $ email , 'token' => str_random ( 40 ) , ] ) ; } $ email = $ invitation -> user_id ? 'spark::emails.team.invitations.existing' : 'spark::emails.team.invitations.new' ; Mail :: send ( $ email , compact ( 'invitation' ) , function ( $ m ) use ( $ invitation ) { $ m -> to ( $ invitation -> email ) -> subject ( 'New Invitation!' ) ; } ) ; return $ invitation ; }
Invite a user to the team by e-mail address.

@param  string  $email
@return \Laravel\Spark\Teams\Invitation
Invite a user to the team by e - mail address .