Example #1
0
 public static function referrerPay(UserTransfer $transfer)
 {
     $seller = $transfer->seller;
     $referrer = $seller->referrer;
     if ($referrer) {
         $share = Config::get('banner.referral_share');
         $referrerShare = $share / 100;
         $amount = $transfer->amount * $referrerShare;
         $amount = round($amount, 2);
         if ($amount == 0) {
             return false;
         }
         $referral = Referral::create(['user_id' => $transfer->seller_id, 'referral_id' => $transfer->seller->referral_id, 'transfer_id' => $transfer->id, 'amount' => $amount, 'currency' => $transfer->currency]);
         $referrer->balance = $referrer->balance + $amount;
         $referrer->save();
         NotificationMapper::referralPaid($referral);
         return true;
     }
     return false;
 }