public function deposit() { //retrieve POST value $param = Input::only('credits', 'account_id'); $rules = array('credits' => 'required|numeric|min:1,max:1000000', 'account_id' => 'exists:acl_users,id'); //custom error messaging $messages = array('buyer_id.exists' => 'Buyer id is not valid.', 'merchant_id.exists' => 'Merchant id is not valid'); $validator = Validator::make($param, $rules, $messages); if ($validator->passes()) { $retrieve = Wallet::where('account_id', $param['account_id'])->first(); $credits = array('account_id' => $param['account_id'], 'credits' => $param['credits']); if (!empty($retrieve)) { try { $update = $retrieve->increment('credits', $param['credits']); if ($update == 1) { $fundin = array('wallet_id' => $retrieve->id, 'onbehalf' => Auth::user()->id, 'credits' => $param['credits'], 'description' => 'Deposit credits', 'fundtype' => 'fundin'); $funds = Fundinout::create($fundin); } } catch (Exception $e) { return false; } } else { $add_credits = Wallet::create($credits); $fundin = array('wallet_id' => $add_credits->id, 'onbehalf' => Auth::user()->id, 'credits' => $param['credits'], 'description' => 'Deposit credits', 'fundtype' => 'fundin'); $funds = Fundinout::create($fundin); } $message = 'Credit has been successfully added.'; return Redirect::action('player.index')->with('success', $message); } else { $messages = $validator->messages(); return Redirect::action('player.index')->with('error', $messages->all()); } }
/** * Create a new blockchain.info bitcoin wallet. * It can be created containing a pre-generated private key or will otherwise generate a new private key. * @param string $api_code API code with create wallets permission. * @param string $password The password for the new wallet. Must be at least 10 characters in length. * @param string $private_key A private key to add to the wallet (Wallet import format preferred). * @param string $label A label to set for the first address in the wallet. Alphanumeric only. * @param string $email An email to associate with the new wallet i.e. the email address of the user you are creating this wallet on behalf of. * @return string */ public static function CreateWallet($api_code, $password, $private_key = "", $label = "", $email = "") { $instance = new Wallet(); return $instance->create($api_code, $password, $private_key, $label, $email); }