From 6e3b1ecb4ba871be5f5b78c0b8de4182abb70eda Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 1 Mar 2016 15:06:54 +1100 Subject: [PATCH] Push Notifications --- app/Http/Controllers/AccountApiController.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 0c4e1c81fa54..6d4ef0ccf1e7 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -125,14 +125,17 @@ class AccountApiController extends BaseAPIController //scan if this user has a token already registered (tokens can change, so we need to use the users email as key) $devices = json_decode($account->devices,TRUE); - if(count($devices) >= 1) { - foreach ($devices as $device) { - if ($device['email'] == Auth::user()->username) { - $device['token'] = $request->token; //update + + for($x=0; $xusername) { + $devices[$x]['token'] = $request->token; //update + $account->devices = json_encode($devices); + $account->save(); return $this->response($account); } } - } + //User does not have a device, create new record $newDevice = [