134 lines
3.6 KiB
PHP
134 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Access;
|
|
|
|
use App\Constant\Constant;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Log;
|
|
use App\Http\Controllers\Api\ApiController;
|
|
use App\Repositories\Api\Access\Notification\NotificationsInterface as NotificationsRepository;
|
|
|
|
class NotificationsController extends ApiController
|
|
{
|
|
/**
|
|
* @var NotificationsRepository
|
|
*/
|
|
protected $notificationsRepository;
|
|
|
|
/**
|
|
* @param NotificationsRepository $notificationsRepository
|
|
* NotificationsController constructor.
|
|
*
|
|
*/
|
|
public function __construct(NotificationsRepository $notificationsRepository)
|
|
{
|
|
$this->notificationsRepository = $notificationsRepository;
|
|
}
|
|
|
|
public function notificationListing(Request $request)
|
|
{
|
|
$response = [];
|
|
|
|
try {
|
|
$response = $this->notificationsRepository->notificationListing($request->all());
|
|
$this->setStatusCode($response['status']);
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
|
|
return $this->respond($response);
|
|
}
|
|
|
|
public function deleteNotification($id)
|
|
{
|
|
$response = [];
|
|
|
|
try {
|
|
$response = $this->notificationsRepository->deleteNotification($id);
|
|
$this->setStatusCode($response['status']);
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
return $this->respond($response);
|
|
}
|
|
|
|
public function deleteAllNotifications()
|
|
{
|
|
$response = [];
|
|
|
|
try {
|
|
$response = $this->notificationsRepository->deleteAllNotifications();
|
|
$this->setStatusCode($response['status']);
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
return $this->respond($response);
|
|
}
|
|
|
|
public function pushNotificationRegister(Request $request)
|
|
{
|
|
$response = [];
|
|
|
|
try{
|
|
$response = $this->notificationsRepository->pushNotificationRegister($request);
|
|
$this->setStatusCode($response['status']);
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
return $this->respond($response);
|
|
}
|
|
|
|
public function deleteUserToken(Request $request)
|
|
{
|
|
$response = [];
|
|
|
|
try{
|
|
$response = $this->notificationsRepository->deleteUserToken($request);
|
|
$this->setStatusCode($response['status']);
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
return $this->respond($response);
|
|
}
|
|
|
|
public function deleteExistingToken(Request $request)
|
|
{
|
|
$response = [];
|
|
|
|
try{
|
|
$response = $this->notificationsRepository->deleteExistingDeviceToken($request);
|
|
$this->setStatusCode($response['status']);
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
return $this->respond($response);
|
|
}
|
|
|
|
public function getUnreadCounts()
|
|
{
|
|
$response = [];
|
|
|
|
try{
|
|
$response = $this->notificationsRepository->getUnreadCounts();
|
|
$this->setStatusCode($response['status']);
|
|
|
|
} catch (\Exception $ex) {
|
|
Log::error($ex);
|
|
$this->setStatusCode(Constant::CODE_403);
|
|
}
|
|
return $this->respond($response);
|
|
}
|
|
}
|