Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/WalletAddTransaction.php
Show All 33 Lines | class WalletAddTransaction extends Command | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$wallet = \App\Wallet::find($this->argument('wallet')); | $wallet = \App\Wallet::find($this->argument('wallet')); | ||||
if (!$wallet) { | if (!$wallet || !$wallet->owner()->withTrashed()->withEnvTenant()->first()) { | ||||
return 1; | return 1; | ||||
} | } | ||||
$qty = (int) $this->argument('qty'); | $qty = (int) $this->argument('qty'); | ||||
$message = $this->option('message'); | $message = $this->option('message'); | ||||
if ($qty < 0) { | if ($qty < 0) { | ||||
$wallet->debit($qty, $message); | $wallet->debit($qty, $message); | ||||
} else { | } else { | ||||
$wallet->credit($qty, $message); | $wallet->credit($qty, $message); | ||||
} | } | ||||
} | } | ||||
} | } |