/** * Handle the command * * @param GetNewRecipientCommand|BaseCommand $command * * @return mixed */ public function handle(BaseCommand $command) { $wallet = $command->wallet; $recipient = new Recipient(['label' => $command->label, 'recipient' => $command->recipient]); $recipient->currency()->associate($command->wallet->currency); $wallet->recipients()->save($recipient); return $recipient; }
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); } }