Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
peripherad
/
app
/
Console
/
Commands
:
AddOrderItemIdToPOItems.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace App\Console\Commands; use App\Models\OrderItems; use App\Models\PurchaseOrderToCreate; use Illuminate\Console\Command; use Illuminate\Support\Facades\Log; class AddOrderItemIdToPOItems extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'email:add-item-ids-to-po-orders'; /** * The console command description. * * @var string */ protected $description = 'Add order item id to items that are not created yet.'; public function handle(): void { $order_items = OrderItems::where('po_created', 0)->get(); foreach ($order_items as $item) { $po_items = PurchaseOrderToCreate::where([ 'order_id' => $item->order_id, 'product_id' => $item->product_id, 'price_id' => $item->price_id, 'quantity' => $item->quantity, ])->get(); foreach ($po_items as $po_item) { $po_item->order_item_id = $item->id; $po_item->save(); } } Log::channel('info_errors') ->info("Record ids updated for PO To Create."); } }