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;
use App\Entity\Card;
use App\Entity\User;
use App\Entity\UserCard;
use App\Entity\UserNotification;
class CardsController extends AbstractController
{
......@@ -63,6 +64,15 @@ class CardsController extends AbstractController
$newUserCard->setGivenDate(new \DateTime());
$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();
}
......
......@@ -42,6 +42,10 @@ class NotificationController extends AbstractController
// SpinPlay
return $this->redirectToRoute('song.detail', ['songId' => $notificationToClear->getConnectedSong()->getId(), 'tab' => 'spinplays']);
break;
case 3:
// Card
return $this->redirectToRoute('user.detail', ['userId' => $notificationToClear->getConnectedUser()->getId()]);
break;
}
} else {
$returnUrl = $request->query->get('returnUrl');
......
......@@ -41,6 +41,11 @@ class UserNotification
*/
private $connectedUser;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Card")
*/
private $connectedCard;
public function getId(): ?int
{
return $this->id;
......@@ -105,4 +110,16 @@ class UserNotification
return $this;
}
public function getConnectedCard(): ?Card
{
return $this->connectedCard;
}
public function setConnectedCard(?Card $connectedCard): self
{
$this->connectedCard = $connectedCard;
return $this;
}
}
......@@ -73,6 +73,8 @@
<div class="notification-icon">
{% if notification.notificationType == 0 %}
<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 %}
<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 %}
......@@ -84,6 +86,8 @@
<strong>{{ notification.connectedUser.username }}</strong> reviewed your chart <strong>{{ notification.connectedSong.title }}</strong>.
{% elseif notification.notificationType == 2 %}
<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 %}
</div>
</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