Moved search logic from controller into Resource model