rexlabsio / smokescreen-laravel-php

Library for integrating the Smokescreen transformation library with the Laravel framework
MIT License
4 stars 1 forks source link

Allow passing class string instead of transformer instance #16

Closed jodiedunlop closed 5 years ago

jodiedunlop commented 6 years ago

The transform() collection() and item() methods, take an optional transformer instance as the second method. When omitted, the transformer resolver is used to try and find a matching transformer and instantiate it via the laravel app container.

It would be nice if you could pass MyTransformer::class (string) as the second argument, meaning that it should be instantiated via laravel's app container.

public function index()
{
    return Smokescreen::transform(User::all(), UserTransformer::class);
}
lachlankrautz commented 5 years ago

Implemented in 2.0.0