Implemented toArray method for models