40 lines
849 B
PHP
Executable File
40 lines
849 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Billing;
|
|
use App\Models\Currency;
|
|
use Illuminate\Console\Command;
|
|
|
|
class BillingCurrencyChange extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'app:billing-currency-change';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$currency = Currency::latest()->first();
|
|
|
|
Billing::chunk(100, function ($billings) use ($currency) {
|
|
foreach ($billings as $billing) {
|
|
$billing->amount = $billing->amount * $currency->dollar;
|
|
$billing->save();
|
|
}
|
|
});
|
|
}
|
|
}
|