Commit fef91f16 authored by SpinShare's avatar SpinShare

added notification for cards

parent 2c3e52f1
...@@ -15,6 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType; ...@@ -15,6 +15,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use App\Entity\Card; use App\Entity\Card;
use App\Entity\User; use App\Entity\User;
use App\Entity\UserCard; use App\Entity\UserCard;
use App\Entity\UserNotification;
class CardsController extends AbstractController class CardsController extends AbstractController
{ {
...@@ -63,6 +64,15 @@ class CardsController extends AbstractController ...@@ -63,6 +64,15 @@ class CardsController extends AbstractController
$newUserCard->setGivenDate(new \DateTime()); $newUserCard->setGivenDate(new \DateTime());
$em->persist($newUserCard); $em->persist($newUserCard);
$newNotification = new UserNotification();
$newNotification->setUser($user);
$newNotification->setNotificationType(3);
$newNotification->setNotificationData("");
$newNotification->setConnectedCard($newUserCard->getCard());
$newNotification->setConnectedUser($user);
$em->persist($newNotification);
$em->flush(); $em->flush();
} }
......
...@@ -42,6 +42,10 @@ class NotificationController extends AbstractController ...@@ -42,6 +42,10 @@ class NotificationController extends AbstractController
// SpinPlay // SpinPlay
return $this->redirectToRoute('song.detail', ['songId' => $notificationToClear->getConnectedSong()->getId(), 'tab' => 'spinplays']); return $this->redirectToRoute('song.detail', ['songId' => $notificationToClear->getConnectedSong()->getId(), 'tab' => 'spinplays']);
break; break;
case 3:
// Card
return $this->redirectToRoute('user.detail', ['userId' => $notificationToClear->getConnectedUser()->getId()]);
break;
} }
} else { } else {
$returnUrl = $request->query->get('returnUrl'); $returnUrl = $request->query->get('returnUrl');
......
...@@ -41,6 +41,11 @@ class UserNotification ...@@ -41,6 +41,11 @@ class UserNotification
*/ */
private $connectedUser; private $connectedUser;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Card")
*/
private $connectedCard;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
...@@ -105,4 +110,16 @@ class UserNotification ...@@ -105,4 +110,16 @@ class UserNotification
return $this; return $this;
} }
public function getConnectedCard(): ?Card
{
return $this->connectedCard;
}
public function setConnectedCard(?Card $connectedCard): self
{
$this->connectedCard = $connectedCard;
return $this;
}
} }
...@@ -73,6 +73,8 @@ ...@@ -73,6 +73,8 @@
<div class="notification-icon"> <div class="notification-icon">
{% if notification.notificationType == 0 %} {% if notification.notificationType == 0 %}
<i class="mdi mdi-server"></i> <i class="mdi mdi-server"></i>
{% elseif notification.notificationType == 3 %}
<div class="cover" style="background-image: url({{ asset("uploads/card/" ~ notification.connectedCard.icon) }});"></div>
{% else %} {% else %}
<div class="cover" style="background-image: url({{ asset("uploads/thumbnail/" ~ notification.connectedSong.fileReference ~ ".jpg?v=" ~ date().timestamp) }}), url({{ asset("assets/img/defaultAlbumArt.jpg") }});"></div> <div class="cover" style="background-image: url({{ asset("uploads/thumbnail/" ~ notification.connectedSong.fileReference ~ ".jpg?v=" ~ date().timestamp) }}), url({{ asset("assets/img/defaultAlbumArt.jpg") }});"></div>
{% endif %} {% endif %}
...@@ -84,6 +86,8 @@ ...@@ -84,6 +86,8 @@
<strong>{{ notification.connectedUser.username }}</strong> reviewed your chart <strong>{{ notification.connectedSong.title }}</strong>. <strong>{{ notification.connectedUser.username }}</strong> reviewed your chart <strong>{{ notification.connectedSong.title }}</strong>.
{% elseif notification.notificationType == 2 %} {% elseif notification.notificationType == 2 %}
<strong>{{ notification.connectedUser.username }}</strong> added a SpinPlay to your chart <strong>{{ notification.connectedSong.title }}</strong>. <strong>{{ notification.connectedUser.username }}</strong> added a SpinPlay to your chart <strong>{{ notification.connectedSong.title }}</strong>.
{% elseif notification.notificationType == 3 %}
You've received the profile card <strong>{{ notification.connectedCard.title }}</strong>.
{% endif %} {% endif %}
</div> </div>
</a> </a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment