<?php

namespace App\Filament\Resources\ProcessOrderResource\Pages;

use App\Filament\Resources\ProcessOrderResource;
use App\Models\ProcessOrder;
use Filament\Actions;
use Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;

class CreateProcessOrder extends CreateRecord
{
    protected static string $resource = ProcessOrderResource::class;

    protected function afterCreate(): void
    {
        $plantId = $this->data['plant_id'];
        $processOrder = $this->data['process_order'];
        $updatedQty = (float) $this->data['updated_order_quantity'];

        ProcessOrder::where('plant_id', $plantId)
            ->where('process_order', $processOrder)
            ->update([
                'updated_order_quantity' => $updatedQty,
                'updated_by' => Filament::auth()->user()->name,
            ]);
    }

}
