public function withdraw($amount, $type = 'withdraw', $meta = [], $shouldAccept = true)
    {
        $accepted = $shouldAccept ? $this->canWithdraw($amount) : true;

        if ($accepted) {
            $this->wallet->balance -= $amount;
            $this->wallet->save();
        } elseif (! $this->wallet->exists) {
            $this->wallet->save();
        }

        $this->wallet->transactions()
            ->create([
                'amount' => $amount,
                'hash' => uniqid('lwch_'),
                'type' => $type,
                'accepted' => $accepted,
                'meta' => $meta
            ]);
    }
public function withdraw($amount, $type = 'withdraw', $meta = [], $shouldAccept = true)
    {
        $accepted = $shouldAccept ? $this->canWithdraw($amount) : true;

        if ($accepted) {
            $this->wallet->balance -= $amount;
            $this->wallet->save();
        } elseif (! $this->wallet->exists) {
            $this->wallet->save();
        }

        $this->wallet->transactions()
            ->create([
                'amount' => $amount,
                'hash' => uniqid('lwch_'),
                'type' => $type,
                'accepted' => $accepted,
                'meta' => $meta
            ]);
    }
public function withdraw ( $ amount , $ type = 'withdraw' , $ meta = [ ] , $ shouldAccept = true ) { $ accepted = $ shouldAccept ? $ this -> canWithdraw ( $ amount ) : true ; if ( $ accepted ) { $ this -> wallet -> balance -= $ amount ; $ this -> wallet -> save ( ) ; } elseif ( ! $ this -> wallet -> exists ) { $ this -> wallet -> save ( ) ; } $ this -> wallet -> transactions ( ) -> create ( [ 'amount' => $ amount , 'hash' => uniqid ( 'lwch_' ) , 'type' => $ type , 'accepted' => $ accepted , 'meta' => $ meta ] ) ; }
Attempt to move credits from this account
@param  integer $amount
@param  string  $type
@param  array   $meta
@param  boolean $shouldAccept
Attempt to move credits from this account