Bug fixes push notifications

This commit is contained in:
David Bomba 2016-03-03 11:24:13 +11:00
parent cc03b4456c
commit 28cd3e01a7
2 changed files with 10 additions and 9 deletions

View File

@ -163,24 +163,25 @@ class AccountApiController extends BaseAPIController
$devices = json_decode($account->devices, TRUE); $devices = json_decode($account->devices, TRUE);
if(count($devices)<1) if(count($devices)<1)
return $this->errorResponse(['message'=>'no devices exist'], 400); return $this->errorResponse(['message'=>'No registered devices.'], 400);
for($x=0; $x<count($devices); $x++) for($x=0; $x<count($devices); $x++)
{ {
if($devices[$x]['email'] == Auth::user()->username) if($devices[$x]['email'] == Auth::user()->username)
{ {
unset($devices[$x]);
$newDevice = [ $newDevice = [
'token' => $request->token, 'token' => $devices[$x]['token'],
'email' => $request->email, 'email' => $devices[$x]['email'],
'device' => $request->device, 'device' => $devices[$x]['device'],
'notify_sent' => $request->notify_sent, 'notify_sent' => $request->notify_sent,
'notify_viewed' => $request->notify_viewed, 'notify_viewed' => $request->notify_viewed,
'notify_approved' => $request->notify_approved, 'notify_approved' => $request->notify_approved,
'notify_paid' => $request->notify_paid, 'notify_paid' => $request->notify_paid,
]; ];
unset($devices[$x]);
$devices[] = $newDevice; $devices[] = $newDevice;
$account->devices = json_encode($devices); $account->devices = json_encode($devices);
$account->save(); $account->save();

8
composer.lock generated
View File

@ -123,12 +123,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/formers/former.git", "url": "https://github.com/formers/former.git",
"reference": "795f7b9b200a4ff4a33b37a96eaaab0229e36325" "reference": "e196c4336db77be97131f6a3b3c3b69b3a22b683"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/formers/former/zipball/795f7b9b200a4ff4a33b37a96eaaab0229e36325", "url": "https://api.github.com/repos/formers/former/zipball/e196c4336db77be97131f6a3b3c3b69b3a22b683",
"reference": "795f7b9b200a4ff4a33b37a96eaaab0229e36325", "reference": "e196c4336db77be97131f6a3b3c3b69b3a22b683",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -174,7 +174,7 @@
"foundation", "foundation",
"laravel" "laravel"
], ],
"time": "2015-11-05 15:53:52" "time": "2016-03-02 17:21:21"
}, },
{ {
"name": "anahkiasen/html-object", "name": "anahkiasen/html-object",