Integrate Mail, Nexmo and Slack notifications into Cachet

This commit is contained in:
James Brooks
2016-12-30 16:22:05 +00:00
parent 056b80a2bc
commit b8a9f41ae4
43 changed files with 1104 additions and 682 deletions
+10 -11
View File
@@ -12,9 +12,18 @@
namespace CachetHQ\Cachet\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
/**
* This is the invite class.
*
* @author Joseph Cohen <joe@alt-three.com>
* @author James Brooks <james@alt-three.com>
*/
class Invite extends Model
{
use Notifiable;
/**
* The attributes that should be casted to native types.
*
@@ -42,21 +51,11 @@ class Invite extends Model
self::creating(function ($invite) {
if (!$invite->code) {
$invite->code = self::generateInviteCode();
$invite->code = str_random(20);
}
});
}
/**
* Returns an invite code.
*
* @return string
*/
public static function generateInviteCode()
{
return str_random(20);
}
/**
* Determines if the invite was claimed.
*
+29 -1
View File
@@ -15,11 +15,19 @@ use AltThree\Validator\ValidatingTrait;
use CachetHQ\Cachet\Presenters\SubscriberPresenter;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use McCool\LaravelAutoPresenter\HasPresenter;
/**
* This is the subscriber model.
*
* @author Joseph Cohen <joe@alt-three.com>
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class Subscriber extends Model implements HasPresenter
{
use ValidatingTrait;
use Notifiable, ValidatingTrait;
/**
* The attributes that should be casted to native types.
@@ -145,6 +153,26 @@ class Subscriber extends Model implements HasPresenter
return str_random(42);
}
/**
* Route notifications for the Nexmo channel.
*
* @return string
*/
public function routeNotificationForNexmo()
{
return $this->phone_number;
}
/**
* Route notifications for the Slack channel.
*
* @return string
*/
public function routeNotificationForSlack()
{
return $this->slack_webhook_url;
}
/**
* Get the presenter class.
*