Exemple #1
0
 public function bind()
 {
     if (($token = Input::get('token')) && ($platform = Input::get('platform')) && in_array($platform, array('android', 'ios', 'chrome', 'safari'))) {
         $device = $this->getDevice();
         $pushToken = PushToken::find((int) $device->id);
         if (!$pushToken) {
             PushToken::where('device_id', $device->id)->delete();
             $pushToken = new PushToken();
             $pushToken->device_id = (int) $device->id;
         }
         $pushToken->token = $token;
         $pushToken->platform = $platform;
         $pushToken->save();
         return $this->respondNoContent();
     } else {
         return $this->respondWithError('Unset necessary parameters');
     }
 }