Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/WalletExpected.php
Show All 32 Lines | class WalletExpected extends Command | ||||
/** | /** | ||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
if ($this->option('user')) { | if ($this->option('user')) { | ||||
$user = \App\User::where('email', $this->option('user')) | $user = \App\User::withEnvTenant() | ||||
->where('email', $this->option('user')) | |||||
->orWhere('id', $this->option('user'))->first(); | ->orWhere('id', $this->option('user'))->first(); | ||||
if (!$user) { | if (!$user) { | ||||
return 1; | return 1; | ||||
} | } | ||||
$wallets = $user->wallets; | $wallets = $user->wallets; | ||||
} else { | } else { | ||||
$wallets = \App\Wallet::all(); | $wallets = \App\Wallet::select('wallets.*') | ||||
->join('users', 'users.id', '=', 'wallets.user_id') | |||||
->withEnvTenant('users') | |||||
->all(); | |||||
} | } | ||||
foreach ($wallets as $wallet) { | foreach ($wallets as $wallet) { | ||||
$charge = 0; | $charge = 0; | ||||
$expected = $wallet->expectedCharges(); | $expected = $wallet->expectedCharges(); | ||||
if (!$wallet->owner) { | if (!$wallet->owner) { | ||||
\Log::debug("{$wallet->id} has no owner: {$wallet->user_id}"); | \Log::debug("{$wallet->id} has no owner: {$wallet->user_id}"); | ||||
Show All 18 Lines |