/**
  * Handle the command
  *
  * @param $command
  *
  * @return mixed
  */
 public function handle(BaseCommand $command)
 {
     $currency = Currency::find($command->currency_id);
     $wallet = new Wallet(['balance' => 0, 'label' => $command->label]);
     $wallet->currency()->associate($currency);
     Auth::user()->wallets()->save($wallet);
     $address = $currency->client->getaccountaddress($wallet->id);
     $wallet->address = $address;
     $wallet->tradekey = Str::random(32, 'alpha');
     $wallet->save();
     return $wallet;
 }
Пример #2
0
 /**
  * @param $value
  *
  * @return mixed|string
  */
 public function getAddressAttribute($value)
 {
     if ($this->category == 'move') {
         $wallet = Wallet::find((int) $this->otheraccount);
         if ($wallet) {
             return $wallet->address;
         }
         return '';
     } else {
         return $value;
     }
 }
 public function handle(BaseCommand $command)
 {
     $sender = $command->sender;
     $address = $command->address;
     $label = $command->label;
     $tradekey = $command->tradekey;
     /** @var Currency $currency */
     $currency = $command->sender->currency;
     if ($address) {
         $currency->client->sendfrom((string) $sender->id, $command->address, $command->amount);
     } elseif ($label) {
         $recipient = Recipient::where(['label' => $label, 'currency_id' => $currency->id])->first();
         $currency->client->sendfrom((string) $sender->id, $recipient->recipient, $command->amount);
     } elseif ($tradekey) {
         $trade = Wallet::where('tradekey', '=', $tradekey)->first();
         $currency->client->move((string) $sender->id, (string) $trade->id, $command->amount);
     }
 }
Пример #4
0
 Route::group(['before' => 'guest'], function () {
     Route::get('login', ['as' => 'login', 'uses' => 'SessionsController@getLogin']);
     Route::post('login', ['as' => 'login', 'uses' => 'SessionsController@postLogin']);
     //Route::controller('password', 'RemindersController');
     Route::get('register', ['as' => 'register', 'uses' => 'RegistrationController@getRegister']);
     Route::post('register', ['as' => 'register', 'uses' => 'RegistrationController@postRegister']);
     Route::get('register/activate', ['as' => 'register.activate', 'uses' => 'RegistrationController@getActivate']);
 });
 /* Logged In Routes */
 Route::group(['before' => 'auth'], function () {
     Route::resource('wallets', 'WalletsController');
     Route::get('wallets/{wallets}/refresh', ['as' => 'wallets.refresh', 'uses' => 'WalletsController@getRefresh']);
     Route::post('wallets/{wallets}/send', ['as' => 'wallets.send', 'uses' => 'WalletsController@postSend']);
     Route::post('wallets/{wallets}/move', ['as' => 'wallets.move', 'uses' => 'WalletsController@postMove']);
     Route::bind('wallets', function ($id) {
         $wallet = Wallet::findOrFail($id);
         if (!Auth::user()->super && $wallet->user_id != Auth::user()->id) {
             throw new Illuminate\Database\Eloquent\ModelNotFoundException('No query results for model [Wallet].');
         }
         return $wallet;
     });
     Route::resource('wallets.addresses', 'AddressesController');
     Route::model('addresses', 'Virtualvendors\\Altwallets\\Address');
     Route::resource('wallets.tradekeys', 'TradeKeysController');
     Route::model('tradekeys', 'Virtualvendors\\Altwallets\\TradeKey');
     Route::resource('wallets.recipients', 'RecipientsController');
     Route::model('recipients', 'Virtualvendors\\Altwallets\\Recipient');
     Route::get('logout', ['as' => 'logout', 'uses' => 'SessionsController@getLogout']);
     /* Admin Routes */
     Route::group(['before' => 'admin', 'prefix' => 'admin', 'namespace' => 'Admin'], function () {
         Route::get('/', ['as' => 'admin.dashboard', 'uses' => 'DashboardController@getIndex']);