Closed CameronDarragh closed 6 years ago
Hey @CameronDarragh thanks for the feedback. I've refactored the type inference in master. Should correctly determine that a plain object is treated as an Item.
You can now also explicitly define that your class is either an item or resource by implementing one of the empty interfaces:
class SomeClass implements \RexSoftware\Laravel\Smokescreen\Resources\ItemResource {}
class SomeClass implements \RexSoftware\Laravel\Smokescreen\Resources\CollectionResource {}
The transform method assumes that anything that isn't a Model is a Collection.
This caused a problem when trying to transform a regular object, in this case AdPreview. Our solution was to just use Smokescreen::item, but transform should be able to pick up that this is not a collection and therefore an item.