<?php

namespace App\Classes\Modules\Steps\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
use App\Models\Step;
use App\Models\Order;

class CreatesManySteps extends AbstractUpdateRelationshipRecord
{

    public function execute(Steppable $owner, array $orderSteps) {

        $orderStepsModel=[];
        foreach($orderSteps as $step){
            $orderStepsModel[]=[
                'appointee_id' => $step->getAppointeeId(),
                'reference' => $step->getReference(),
                'primary' => $step->getPrimary(),
                'sequence' => $step->getSequence(),
                'status' => 0,
                'contract_status' => 0,
                'unity_hash_id' => $step->getHashId(),
            ];
        }

        Step::insert($orderStepsModel);
        //$order->orderSteps()->createMany($orderStepsModel);

    }
}
