43 lines
1.1 KiB
PHP
Executable File
43 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Currency;
|
|
use App\Models\Order;
|
|
use Illuminate\Console\Command;
|
|
|
|
class OrderCurrencyChange extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'app:order-currency-change';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$currency = Currency::latest()->first();
|
|
|
|
Order::chunk(100, function ($orders) use ($currency) {
|
|
foreach ($orders as $order) {
|
|
$order->price_products = $order->price_products * $currency->dollar;
|
|
$order->price_delivery = $order->price_delivery * $currency->dollar;
|
|
$order->price_total = $order->price_total * $currency->dollar;
|
|
$order->price_master = $order->price_master * $currency->dollar;
|
|
$order->save();
|
|
}
|
|
});
|
|
}
|
|
}
|