<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Pimcore\Controller\FrontendController;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
use \Pimcore\Model\DataObject\City;
use \Pimcore\Model\DataObject\Ward;
use \Pimcore\Model\DataObject\District;
use Pimcore\Model\DataObject\Service as DataObjectService;
use Pimcore\Model\DataObject;
use Pimcore\Model\Notification\Service\NotificationService;
use Pimcore\Db;
class DefaultController extends BaseController
{
private $notificationService;
public function __construct(
NotificationService $notificationService
)
{
$this->notificationService = $notificationService;
}
/**
* @Route("/notifications", name="notifications")
*/
public function notifications(Request $request)
{
$queryBuilder = Db::getConnection()->createQueryBuilder();
$queryBuilder->addSelect([
'count(notifications.id) as total'
]);
$queryBuilder->from('notifications', 'notifications');
$queryBuilder->andWhere('notifications.read = 0');
$result = $queryBuilder->execute()->fetchAll();
$data=0;
foreach($result as $value){
$data = $value['total'];
}
return $this->sendResponse(['total' => $data]);
}
/**
* @Template
* @param Request $request
* @return array
*/
public function defaultAction(Request $request)
{
return [];
}
}