![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ledger.corals.io/Corals/modules/Ledger/update-batches/ |
<?php \Illuminate\Support\Facades\Schema::table('ledger_items', function (\Illuminate\Database\Schema\Blueprint $table) { $table->decimal('quantity')->after('wholesale_price')->default(0); }); \Corals\Modules\Ledger\Models\Item::query()->each(function ($item) { $item->update([ 'quantity' => \Corals\Modules\Ledger\Models\RecordItems::query()->where('item_id', $item->id)->sum('quantity') ]); });