48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Notification;
|
|
use App\Models\OnesignalAgent;
|
|
use App\Models\OnesignalUser;
|
|
use App\Traits\ApiResponser;
|
|
use Illuminate\Http\Request;
|
|
use Berkayk\OneSignal\OneSignalFacade;
|
|
use Mockery\Matcher\Not;
|
|
|
|
class NotificationController extends Controller
|
|
{
|
|
use ApiResponser;
|
|
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
public function getNotifcations(Request $request)
|
|
{
|
|
$this->validate($request, [
|
|
'user_code' => 'required_without:agent_code',
|
|
'agent_code' => 'required_without:user_code'
|
|
]);
|
|
$notifications = [];
|
|
if (isset($request->user_code))
|
|
$notifications = Notification::where('user_code', $request->user_code)->get();
|
|
elseif (isset($request->agent_code))
|
|
$notifications = Notification::where('agent_code', $request->agent_code)->get();
|
|
|
|
foreach ($notifications as $notif) {
|
|
$notif->data = json_decode($notif->data);
|
|
}
|
|
|
|
return $this->successResponse($notifications);
|
|
}
|
|
|
|
|
|
}
|