Initial commit as of 2018-10-16
This commit is contained in:
46
application/models/notifications/NewFollowerNotification.php
Normal file
46
application/models/notifications/NewFollowerNotification.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Notification\Users;
|
||||
|
||||
use Notification;
|
||||
|
||||
require_once 'Notification.php';
|
||||
|
||||
class NewFollowerNotification extends \Notification
|
||||
{
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$data['type'] = 'users.newFollower';
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
public function getNotificationLink()
|
||||
{
|
||||
return '/user/' . $this->recipient->getUsername() . '/followers';
|
||||
}
|
||||
|
||||
public function getNotificationImage()
|
||||
{
|
||||
return $this->sender->getProfilePicture();
|
||||
}
|
||||
|
||||
public function messageForNotification(Notification $notification)
|
||||
{
|
||||
return ['line' => 'users.newFollower.single', 'attributes' => [$this->sender->getName()]];
|
||||
}
|
||||
|
||||
public function messageForNotifications(array $notifications, $realCount = 0)
|
||||
{
|
||||
if ($realCount === 0) {
|
||||
$realCount = count($notifications);
|
||||
}
|
||||
|
||||
if ($realCount < 5) {
|
||||
$names = $this->manyNames($notifications);
|
||||
return ['line' => 'users.newFollower.multiple', 'attributes' => [$names]];
|
||||
} else {
|
||||
$names = $this->manyNamesCutoff($notifications, $realCount);
|
||||
return ['line' => 'users.newFollower.many', 'attributes' => [$names]];
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user