restore composer.json, add mysqli extension
This commit is contained in:
42
app/Console/Commands/OrderCurrencyChange.php
Executable file
42
app/Console/Commands/OrderCurrencyChange.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user