public static function setProperty(&$objectOrArray, $property, $value)
    {
        // Eloquent models are also instances of ArrayAccess, and therefore
        // we check for that first
        if ($objectOrArray instanceof EloquentModel) {
            // Does relation exist?
            // If so, only set the relation if not primitive. Keeping a attribute
            // as a relation will allow for it to be converted to arrays during
            // serialization
            if ($property) {
                if ($objectOrArray->relationLoaded($property) && !Utility::isPrimitive($value)) {
                    $objectOrArray->setRelation($property, $value);

            // If attribute is not a relation we just set it on
            // the model directly. If it is a primitive relation (a relation
            // converted to IDs) we unset the relation and set it as an attribute
                } else {
                    unset($objectOrArray[$property]);
                    $objectOrArray->setAttribute($property, $value);
                }
            }
        } elseif (is_array($objectOrArray)) {
            $objectOrArray[$property] = $value;
        } else {
            $objectOrArray->{$property} = $value;
        }
    }