fix order shipped basket as empty on DB

This commit is contained in:
Jérémy Munsch 2023-03-20 09:27:05 +01:00
parent 279f0f40f9
commit 7c4fffd25e
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -0,0 +1,30 @@
<?php
use App\Models\Shop\Order;
use Illuminate\Database\Migrations\Migration;
class FixShippedBasketOnOrders extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Order::query()->get()->each(function (Order $order) {
$order->shipped_basket = $order->shipped_basket ?? [];
$order->saveQuietly();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Dont do anything.
}
}