Added conditional to buildDictionary foreach loop

Thanks for implementing polymorphic eager loading!

Came across an issue where the morphType field in the database was null and caused `Class '' not found` from `createModelByType` function.

Added conditional to `buildDictionary` method to fix situations where morphType is null