<?php

declare(strict_types=1);

namespace {{ tree.getFullNameSpaceOfFile(file, entity, action) }};

use App\Models\User;
{% for dependency in dependencyzz %}
use {{ dependency }};{% endfor %}

class {{ helper.getClassName(file, entity, action) }}
{
    public function __construct(private {{ helper.getClassName(helper.findFile('CreateOneItem'), entity, 'CreateOne') }} $CreateOne)
    {
    }

    /**
     * @param  array<int, array<string, mixed>>  $Datazz
     * @return array<int, {{ helper.getClassName(helper.findFile('Model'), entity, action) }}>
     */
    function run(int $UserId, array $Datazz): array
    {
        /** @var array<int, int> $Idzz */
        $Idzz = [];
        /** @var array<int, {{ helper.getClassName(helper.findFile('Model'), entity, action) }}> $Itemzz */
        $Itemzz = [];
        foreach ($Datazz as $Data) {
            $Item = $this->CreateOne->make(
                $UserId,
{% for column in columnzz %}
                $Data['{{ column.name }}'],{% endfor %}
            );
            $this->CreateOne->create($Item);
            $Idzz[] = $Item->Id;
            $Itemzz[] = $Item;
        }

        event(new {{ action + entity.name }}Event($Idzz));

        return $Itemzz;
    }

}
