Add withPrimaryKey to toArray
Fix unused $primaryKey