Example #1
0
 /**
  * Create social user
  * 
  * @param array $data
  * @param string $deviceId
  * @param mixed(integer|null) $user
  */
 private function _createSocialUser($data, $deviceId, $user = NULL)
 {
     $lastInsertId = empty($user) ? 0 : $user->id;
     $dbKeys = array('user_name', 'email_id', 'facebook_id');
     if (empty($user)) {
         $saveUserData = array();
         foreach ($dbKeys as $key => $value) {
             if (isset($data[$value])) {
                 $saveUserData[$value] = $data[$value];
             }
         }
         $saveUserData['registerd_by'] = $data['login_by'];
         $saveUserData['status'] = 'active';
         $saveUserData['created_at'] = date('Y-m-d H:i:s');
         $lastInsertId = UserModel::insertGetId($saveUserData);
     }
     $token = $this->mapUserAndDevice($lastInsertId, $deviceId, $data['type'], $data['push_token']);
     $this->messages['access_token'] = $token;
     $this->messages['status'] = $this->successStatus;
     $userData = UserModel::select('user_name', 'email_id', 'mobile_no')->where('id', '=', $lastInsertId)->get()->toArray();
     $this->messages['data']['Success'] = $userData;
 }