Skip to content

Commit

Permalink
Add Feature Check Balance
Browse files Browse the repository at this point in the history
  • Loading branch information
irfaardy committed Sep 2, 2020
1 parent d3b4683 commit f15d7d2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
44 changes: 39 additions & 5 deletions src/Core/DompetCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ protected function addBalance($ammount,$note = null,$transaction_id = null)
$this->message = Lang::get('dompet.pin.invalid');
return false;
}

/**
* Method ini untuk melakukan pengurangan saldo
*
* @return boolean
*/
protected function reduceBalance($ammount,$note = null,$transaction_id = null)

{
Expand All @@ -49,8 +53,12 @@ protected function reduceBalance($ammount,$note = null,$transaction_id = null)
$this->message = Lang::get('dompet.pin.invalid');
return false;
}

protected function reduceSaldo($ammount,$note=null,$transaction_id=null)
/**
* Method ini untuk Pengurangan saldo
*
* @return boolean
*/
protected function reduceSaldo($ammount,$note=null,$transaction_id=null)

{
if(Dompet::create(['user_id' => $this->user_id,'balance' => DB::raw("-".$ammount),'annotation'=>$note,
Expand All @@ -60,14 +68,36 @@ protected function reduceSaldo($ammount,$note=null,$transaction_id=null)

return false;
}
protected function addSaldo($ammount,$note=null,$transaction_id=null)

{
if(Dompet::create(['user_id' => $this->user_id,'balance' => $ammount,'annotation'=>$note,
'transaction_id'=>$transaction_id])){
return true;
}

return false;
}
/**
* Method ini untuk melakukan perhitungan jumlah saldo dari user yang sudah ditentukan
*
* @return float
*/
protected function totalBalance($formated = false){
$sum = Dompet::where('user_id',$this->user_id)->sum('balance');
if($formated)
{
$sum = number_format($sum);
}
return $sum;
}

/**
* Method ini untuk melakukan permintaan penarikan dana ke admin website
*
* @return boolean
*/
protected function account($user_id,$pin){
protected function account($user_id,$pin=null){
$this->user_id = $user_id;
$this->pin = $pin;

Expand Down Expand Up @@ -101,7 +131,11 @@ protected function update($newPin)
$this->message = Lang::get('dompet.pin.invalid');
return false;
}

/**
* Method ini untuk melakukan Balidasi Akun
*
* @return boolean
*/
protected function validate()

{
Expand Down
6 changes: 3 additions & 3 deletions src/Saku/Dompet.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function withdrawal()
* @param integer $userId
* @return float
*/
public function sumBalance($userId){

public function sumBalance($formatted=false){
return $this->account($this->userId)->totalBalance($formatted);
}
/**
* Method ini untuk membuat Pin Baru
Expand Down Expand Up @@ -58,7 +58,7 @@ public function updatePin($newPin)
* @param string $pin
* @return $this;
*/
public function credential($userId,$pin)
public function credential($userId,$pin=null)

{
$this->userId = $userId;
Expand Down

0 comments on commit f15d7d2

Please sign in to comment.