*/ public function via(object $notifiable): array { return ['mail']; } /** * Get the mail representation of the notification. */ public function toMail(TeamInvite $invite): MailMessage { $user = User::whereEmail($invite->invited_email)->first(); return (new MailMessage) ->subject('Team Invitation') ->greeting( $user !== null ? sprintf('Hello %s,', $user->name) : 'Hello', ) ->line(sprintf( '%s invited you to the %s team.', $invite->invitedBy->name, $invite->team->name, )) ->linesIf($user === null, [ 'It seems like you don\'t have an account yet.', 'Create one now for free to join the team.', ]) ->action($user === null ? 'Register and join this team' : 'Join this team', route($user === null ? 'register' : 'teams.invite.create', ['inviteToken' => $invite->plainInviteToken()] + ( $user === null ? ['email' => $invite->invited_email] : [] ) )); } /** * Get the array representation of the notification. * * @return array */ public function toArray(object $notifiable): array { return [ // ]; } }