src/Transformations/TransformationFactory.php
public function resourceWith($entity, $transformer, $key = null): TransformationFactory
	{
		// if collection, paginator, or array with first value being an array use collection resource.
		if ((is_array($entity) && isset($entity[0]) && is_array($entity[0])) || $entity instanceof LaravelCollection || $entity instanceof LengthAwarePaginator) {
			return $this->collectionWith($entity, $transformer, $key);
		}

		return $this->itemWith($entity, $transformer, $key);
	}
public function resourceWith($entity, $transformer, $key = null): TransformationFactory
	{
		// if collection, paginator, or array with first value being an array use collection resource.
		if ((is_array($entity) && isset($entity[0]) && is_array($entity[0])) || $entity instanceof LaravelCollection || $entity instanceof LengthAwarePaginator) {
			return $this->collectionWith($entity, $transformer, $key);
		}

		return $this->itemWith($entity, $transformer, $key);
	}
public function resourceWith ( $ entity , $ transformer , $ key = null ) : TransformationFactory { // if collection, paginator, or array with first value being an array use collection resource. if ( ( is_array ( $ entity ) && isset ( $ entity [ 0 ] ) && is_array ( $ entity [ 0 ] ) ) || $ entity instanceof LaravelCollection || $ entity instanceof LengthAwarePaginator ) { return $ this -> collectionWith ( $ entity , $ transformer , $ key ) ; } return $ this -> itemWith ( $ entity , $ transformer , $ key ) ; }
Adds data and transformer, and chooses whether to use the Item or Collection Resource
based on what's most suitable for the data passed in.

@param mixed                        $entity
@param TransformerAbstract|callable $transformer
@param null|mixed                   $key

@return \Fuzz\Data\Transformations\TransformationFactory
Adds data and transformer and chooses whether to use the Item or Collection Resource based on what s most suitable for the data passed in .