Made hasMany query work