src/Routing/VersionedHelpers.php
protected function serializeWith($instance, string $name)
    {
        $serializer = $this->getVersionedResourceClassName('Serializers', $name);

        if (\class_exists($serializer)) {
            return \call_user_func(app($serializer), $instance);
        }

        if ($instance instanceof Fluent) {
            return $instance->getAttributes();
        } elseif ($instance instanceof Collection) {
            return $instance->all();
        } elseif ($instance instanceof Arrayable) {
            return $instance->toArray();
        }

        return $instance;
    }
protected function serializeWith($instance, string $name)
    {
        $serializer = $this->getVersionedResourceClassName('Serializers', $name);

        if (\class_exists($serializer)) {
            return \call_user_func(app($serializer), $instance);
        }

        if ($instance instanceof Fluent) {
            return $instance->getAttributes();
        } elseif ($instance instanceof Collection) {
            return $instance->all();
        } elseif ($instance instanceof Arrayable) {
            return $instance->toArray();
        }

        return $instance;
    }
protected function serializeWith ( $ instance , string $ name ) { $ serializer = $ this -> getVersionedResourceClassName ( 'Serializers' , $ name ) ; if ( \ class_exists ( $ serializer ) ) { return \ call_user_func ( app ( $ serializer ) , $ instance ) ; } if ( $ instance instanceof Fluent ) { return $ instance -> getAttributes ( ) ; } elseif ( $ instance instanceof Collection ) { return $ instance -> all ( ) ; } elseif ( $ instance instanceof Arrayable ) { return $ instance -> toArray ( ) ; } return $ instance ; }
Serialize the instance.

@param  mixed  $instance
@param  string  $name

@return array
Serialize the instance .