Ejemplo n.º 1
0
 /**
  * Update GCM token for registered user so they could control mobile notifications.
  *
  * @param $userId contributor ID
  * @param $gcmToken generated token from google
  */
 public function registerGcmToken($userId, $gcmToken)
 {
     $contributor = Contributor::find($userId);
     if ($contributor != null) {
         $contributor->gcm_token = $gcmToken;
         $contributor->save();
     }
 }
 /**
  * Find out accumulation of deferred transaction before, 'deferred transaction' means
  * all withdrawal request which does not proceed yet by admin and contributor's balance
  * never touch (subtracted) so it need to recalculate again before next request comes in.
  *
  * @param $contributor_id
  * @return mixed
  */
 private function getDefferWithdrawal($contributor_id)
 {
     return Contributor::find($contributor_id)->transactions()->whereType(Transaction::TYPE_WITHDRAWAL)->where(function ($query) {
         $query->where('status', '=', Transaction::STATUS_PENDING);
         $query->orWhere('status', '=', Transaction::STATUS_PROCEED);
     })->sum('amount');
 }