Update Factory.php to fix bug.

Factory.php was not taking into account fields that have `{$class}_id` as their primary key instead of `id` eg `user_id` as the primary key for the `users` table. - fixed and tests still pass