Service in a trasnformer laravel

Viewed 12

I am a junior and I want to ask if it is possible or is it good practice to put a service on a trasformer.

My transformer is like this:

public function transform(InventarioStock $inventarioStock)
    {
        return [
            'id' => $inventarioStock->id,
            'lote' => $inventarioStock->lote,
            'vencimiento' => $inventarioStock->vencimiento,
            'cantidad' => $inventarioStock->cantidad - $stockAsignado,
        ];
    }

y lo quiero poner asi

public function transform(InventarioStock $inventarioStock, InventarioSotockService $service)
    {
        return $service->noAsign($invetarioStock);
    }

In other words, it is good practice or it is not recommended.

Thanks in advance.

0 Answers
Related