示例#1
1
 public function wallet()
 {
     $wallet = Wallet::where('user_id', '=', $this->id)->get();
     if (count($wallet) != 0) {
         $wallet = $wallet->first();
     } else {
         $wallet = new Wallet();
         $wallet->user_id = $this->id;
         $wallet->account_id = $this->account_id;
         $wallet->save();
     }
     return $wallet;
 }
示例#2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Wallet();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Wallet'])) {
         $model->attributes = $_POST['Wallet'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->transactionID));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function actionCreate()
 {
     $sock = stream_socket_client('unix:///tmp/addr_server_socket', $errno, $errstr);
     fwrite($sock, "request_addr\n");
     $data = fread($sock, 4096) . "\n";
     fclose($sock);
     if ($data != "") {
         $data = json_decode($data);
     } else {
         $this->redirect(Yii::t('urls', '/wallets'));
     }
     $user = Yii::app()->user->data();
     $wallets = $user->wallets;
     $new_wallet = new Wallet();
     $new_wallet->id_user = $user->id;
     $new_wallet->wallet_address = $data->{'multiaddr'};
     $new_wallet->privatekey = $data->{'key1'};
     $new_wallet->save();
     $this->render('created', array('wallets' => $wallets, 'data' => $data));
 }
 public function addNewWallet()
 {
     $type = strtoupper(Input::get('type'));
     $name = Input::get('name');
     $wallet_username = Input::get('wallet_username');
     $password = Input::get('password');
     $ip = Input::get('ip');
     $port = Input::get('port');
     $limit_confirmations = Input::get('limit_confirmations');
     $is_moneypaper = Input::get('is_moneypaper');
     $enable_deposit = Input::get('enable_deposit');
     $enable_withdraw = Input::get('enable_withdraw');
     $download_wallet_client = Input::get('download_wallet_client');
     $check_wallet = Wallet::where('type', '=', $type)->first();
     if (isset($check_wallet->id)) {
         return Redirect::to('admin/manage/wallets')->with('error', Lang::get('admin_messages.wallet_exist'));
     }
     $logo_coin = Input::file('logo_coin');
     $logo = '';
     if (!empty($logo_coin)) {
         $extension = $logo_coin->getClientOriginalExtension();
         $destinationPath = 'upload/images/';
         $fileName = time() . '.' . $extension;
         if (in_array($extension, array('jpg', 'png', 'gif'))) {
             if ($logo_coin->move($destinationPath, $fileName)) {
                 $logo = $destinationPath . $fileName;
             }
         } else {
             return Redirect::to('admin')->with('notice', 'The extension of image invalid');
         }
     }
     $wallet = new Wallet();
     $wallet->type = $type;
     $wallet->name = $name;
     $wallet->wallet_username = $wallet_username;
     $wallet->wallet_password = $password;
     $wallet->wallet_ip = $ip;
     $wallet->port = $port;
     $wallet->limit_confirmations = $limit_confirmations;
     $wallet->download_wallet_client = $download_wallet_client;
     $wallet->logo_coin = $logo;
     $wallet->is_moneypaper = !empty($is_moneypaper) ? $is_moneypaper : 0;
     $wallet->enable_deposit = !empty($enable_deposit) ? $enable_deposit : 0;
     $wallet->enable_withdraw = !empty($enable_withdraw) ? $enable_withdraw : 0;
     $wallet->save();
     if ($wallet->id) {
         $fee_withdraw = new FeeWithdraw();
         $fee_withdraw->wallet_id = $wallet->id;
         $fee_withdraw->percent_fee = 0;
         $fee_withdraw->save();
         return Redirect::to('admin/manage/wallets')->with('success', Lang::get('admin_messages.created_success_param', array('object' => $wallet->name)));
     } else {
         return Redirect::to('admin/manage/wallets')->with('error', Lang::get('admin_messages.not_create_wallet'));
     }
 }