/** * 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; }
/** * @return array */ public function getNetWorthAttribute() { $balances = []; /** @var \Virtualvendors\Altwallets\Calculators\AltcoinConverter $converter */ $converter = App::make('Virtualvendors\\Altwallets\\Calculators\\AltcoinConverter'); foreach ($this->wallets as $wallet) { if (!array_key_exists($wallet->currency_id, $balances)) { $balances[$wallet->currency_id] = 0; } $balances[$wallet->currency_id] += $wallet->balance; } $worths = []; foreach ($balances as $currency_id => $balance) { /** @var Currency $currency */ $currency = Currency::find($currency_id); $worths[$currency->code] = $converter->convert($currency, $balance); } return $worths; }
/** * Handle the command * * @param NewCurrencyCommand|BaseCommand $command * * @return mixed */ public function handle(BaseCommand $command) { $currency = Currency::create($command->all()); return $currency; }
/** * Display the specified resource. * * @param Currency $currency * * @internal param int $id * @return \Response */ public function show(Currency $currency) { $currency->load('wallets.user'); $this->view('admin.currencies.show', compact('currency')); }
/** * Show the form for creating a new resource. * @return Response */ public function create() { $currencies = Currency::all(); $this->view('wallets.create', compact('currencies')); }
/** * @param $message * @param $attribute * @param $rule * @param $parameters * * @return mixed */ public function replaceValidCoinAddress($message, $attribute, $rule, $parameters) { return str_replace(':currency', Currency::find($parameters[0])->code, $message); }