app/controllers/DestinationsController.java
@Security.Authenticated(SecureSession.class)
    public CompletionStage<Result> search(Http.Request request, Integer rowOffset){
        Integer profId = SessionController.getCurrentUserId(request);
        searchVal = "";
        return profileRepository.findById(profId).thenApplyAsync(profile -> {
            if (profile.isPresent()) {
                Form<DestinationSearchFormData> searchDestinationForm = searchForm.bindFromRequest(request);
                DestinationSearchFormData searchData = searchDestinationForm.get();
                if (searchData.name.equals("")) {
                    return redirect(destShowRoute).flashing("error",
                            "Please enter a destination name to search");
                }
                if (searchVal == null || searchVal.equals("")) {
                    searchVal = searchData.name;
                }
                destinationsList = destinationRepository.searchDestinations(searchData.name, rowOffset,
                        searchData.isPublic, profId);
                destinationsList = loadCurrentUserDestinationPhotos(profile.get().getProfileId(), destinationsList);
                destinationsList = loadWorldDestPhotos(profile.get().getProfileId(), destinationsList);
                destinationsList = loadTravellerTypes(destinationsList);
                int sizeOfSearchResults = destinationRepository.getNumSearchDestinations(searchData.name,
                        searchData.isPublic, profId);
                PaginationHelper paginationHelper = makePagination(rowOffset, sizeOfSearchResults);
                List<Photo> usersPhotos = getUsersPhotos(profile.get().getProfileId());

                return ok(destinations.render(destinationsList, profile.get(), searchData.isPublic, paginationHelper,
                        followedDestinationIds, usersPhotos, form,
                        new RoutedObject<Destination>(null, false, false), requestForm,
                        Country.getInstance().getAllCountries(),
                        searchDestinationForm, searchVal,
                        request, messagesApi.preferred(request)));
            } else {
                return redirect(destShowRoute);
            }
        });
    }
/**
     * Function to search for a destination
     * @param request HTTP request
     * @return result rendering the destination page with searched destinations results
     */
Function to search for a destination
@param request HTTP request
@return result rendering the destination page with searched destinations results
Function to search for a destination @param request HTTP request @return result rendering the destination page with searched destinations results
@Security.Authenticated(SecureSession.class)
    public CompletionStage<Result> search(Http.Request request, Integer rowOffset){
        Integer profId = SessionController.getCurrentUserId(request);
        searchVal = "";
        return profileRepository.findById(profId).thenApplyAsync(profile -> {
            if (profile.isPresent()) {
                Form<DestinationSearchFormData> searchDestinationForm = searchForm.bindFromRequest(request);
                DestinationSearchFormData searchData = searchDestinationForm.get();
                if (searchData.name.equals("")) {
                    return redirect(destShowRoute).flashing("error",
                            "Please enter a destination name to search");
                }
                if (searchVal == null || searchVal.equals("")) {
                    searchVal = searchData.name;
                }
                destinationsList = destinationRepository.searchDestinations(searchData.name, rowOffset,
                        searchData.isPublic, profId);
                destinationsList = loadCurrentUserDestinationPhotos(profile.get().getProfileId(), destinationsList);
                destinationsList = loadWorldDestPhotos(profile.get().getProfileId(), destinationsList);
                destinationsList = loadTravellerTypes(destinationsList);
                int sizeOfSearchResults = destinationRepository.getNumSearchDestinations(searchData.name,
                        searchData.isPublic, profId);
                PaginationHelper paginationHelper = makePagination(rowOffset, sizeOfSearchResults);
                List<Photo> usersPhotos = getUsersPhotos(profile.get().getProfileId());
                return ok(destinations.render(destinationsList, profile.get(), searchData.isPublic, paginationHelper,
                        followedDestinationIds, usersPhotos, form,
                        new RoutedObject<Destination>(null, false, false), requestForm,
                        Country.getInstance().getAllCountries(),
                        searchDestinationForm, searchVal,
                        request, messagesApi.preferred(request)));
            } else {
                return redirect(destShowRoute);
            }
        });
    }
@ Security . Authenticated ( SecureSession . class ) public CompletionStage < Result > search ( Http . Request request , Integer rowOffset ) { Integer profId = SessionController . getCurrentUserId ( request ) ; searchVal = "" ; return profileRepository . findById ( profId ) . thenApplyAsync ( profile -> { if ( profile . isPresent ( ) ) { Form < DestinationSearchFormData > searchDestinationForm = searchForm . bindFromRequest ( request ) ; DestinationSearchFormData searchData = searchDestinationForm . get ( ) ; if ( searchData . name . equals ( "" ) ) { return redirect ( destShowRoute ) . flashing ( "error" , "Please enter a destination name to search" ) ; } if ( searchVal == null || searchVal . equals ( "" ) ) { searchVal = searchData . name ; } destinationsList = destinationRepository . searchDestinations ( searchData . name , rowOffset , searchData . isPublic , profId ) ; destinationsList = loadCurrentUserDestinationPhotos ( profile . get ( ) . getProfileId ( ) , destinationsList ) ; destinationsList = loadWorldDestPhotos ( profile . get ( ) . getProfileId ( ) , destinationsList ) ; destinationsList = loadTravellerTypes ( destinationsList ) ; int sizeOfSearchResults = destinationRepository . getNumSearchDestinations ( searchData . name , searchData . isPublic , profId ) ; PaginationHelper paginationHelper = makePagination ( rowOffset , sizeOfSearchResults ) ; List < Photo > usersPhotos = getUsersPhotos ( profile . get ( ) . getProfileId ( ) ) ; return ok ( destinations . render ( destinationsList , profile . get ( ) , searchData . isPublic , paginationHelper , followedDestinationIds , usersPhotos , form , new RoutedObject < Destination > ( null , false , false ) , requestForm , Country . getInstance ( ) . getAllCountries ( ) , searchDestinationForm , searchVal , request , messagesApi . preferred ( request ) ) ) ; } else { return redirect ( destShowRoute ) ; } } ) ; }
Function to search for a destination
 @param request HTTP request
 @return result rendering the destination page with searched destinations results
Function to search for a destination @param request HTTP request @return result rendering the destination page with searched destinations results