Added messages, notifications, count, and supporting elements
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Messages;
|
||||
use App\Entity\User;
|
||||
use App\Libs\Breadcrumb;
|
||||
use App\Libs\NavList;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@@ -14,6 +16,14 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
||||
|
||||
class DefaultController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Variable to store unread notification messages
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private array $msgs;
|
||||
|
||||
private int $notificationCount = 0;
|
||||
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
@@ -27,6 +37,8 @@ class DefaultController extends AbstractController
|
||||
public function dashboard(Request $request, #[CurrentUser()] ?User $user): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
|
||||
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
|
||||
|
||||
if (!$user->getCompany()) {
|
||||
return $this->redirectToRoute('app_register_step', ['step' => RegistrationController::REGISTER_STEP_TWO]);
|
||||
@@ -40,9 +52,10 @@ class DefaultController extends AbstractController
|
||||
$this->navLinks,
|
||||
[
|
||||
'breadcrumbs' => [
|
||||
'Dashboard'
|
||||
new Breadcrumb('', 'Dashboard')
|
||||
],
|
||||
'notifications' => $user->retrieveUnreadNotifications(),
|
||||
'notifications' => $this->msgs,
|
||||
'notificationCount' => $this->notificationCount,
|
||||
]
|
||||
)
|
||||
);
|
||||
@@ -52,6 +65,8 @@ class DefaultController extends AbstractController
|
||||
public function profile(#[CurrentUser()] User $user): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||
$this->msgs = $this->entityManager->getRepository(Messages::class)->getUnreadMessages($user);
|
||||
$this->notificationCount = $this->entityManager->getRepository(Messages::class)->getUnreadMessageCount($user);
|
||||
|
||||
$this->navLinks['profile'] = NavList::PRESENT_LINK;
|
||||
|
||||
@@ -61,9 +76,10 @@ class DefaultController extends AbstractController
|
||||
$this->navLinks,
|
||||
[
|
||||
'breadcrumbs' => [
|
||||
'Profile'
|
||||
new Breadcrumb('', 'Profile')
|
||||
],
|
||||
'notifications' => $user->retrieveUnreadNotifications(),
|
||||
'notifications' => $this->msgs,
|
||||
'notificationCount' => $this->notificationCount,
|
||||
]
|
||||
)
|
||||
);
|
||||
|
Reference in New Issue
Block a user