This document describes the enhanced search filter functionality added to the Liberu Real Estate Laravel application. These enhancements enable users to filter properties based on energy efficiency, walkability, transit accessibility, bike-friendliness, featured status, and country location.
- Type: Dropdown selection (A-G)
- Description: Filter properties by their energy efficiency rating
- Usage: Select from A (most efficient) to G (least efficient)
- Database Field:
energy_rating(string)
- Type: Numeric input (0-100)
- Description: Filter properties with a minimum energy score
- Usage: Enter a number from 0 to 100
- Database Field:
energy_score(integer)
- Type: Numeric input (0-100)
- Description: Filter properties with a minimum walkability score
- Usage: Higher scores indicate better pedestrian access to amenities
- Database Field:
walkability_score(tinyInteger) - Note: Scores are updated via WalkScore API integration
- Type: Numeric input (0-100)
- Description: Filter properties with a minimum public transit accessibility score
- Usage: Higher scores indicate better access to public transportation
- Database Field:
transit_score(tinyInteger)
- Type: Numeric input (0-100)
- Description: Filter properties with a minimum bike-friendliness score
- Usage: Higher scores indicate better cycling infrastructure
- Database Field:
bike_score(tinyInteger)
- Type: Dropdown selection
- Description: Filter properties by country
- Usage: Select from available countries (UK, US, FR, DE, ES)
- Database Field:
country(string) - Note: Useful for international property listings
- Type: Checkbox
- Description: Show only featured/premium properties
- Usage: Check to display only properties marked as featured
- Database Field:
is_featured(boolean)
The following Eloquent query scopes were added to app/Models/Property.php:
// Filter by energy rating (A-G)
public function scopeEnergyRating(Builder $query, $rating): Builder
// Filter by minimum energy score
public function scopeMinEnergyScore(Builder $query, $minScore): Builder
// Filter by minimum walkability score
public function scopeWalkabilityScore(Builder $query, $minScore): Builder
// Filter by minimum transit score
public function scopeTransitScore(Builder $query, $minScore): Builder
// Filter by minimum bike score
public function scopeBikeScore(Builder $query, $minScore): Builder
// Filter featured properties only
public function scopeFeatured(Builder $query): Builder
// Filter by country
public function scopeCountry(Builder $query, $country): BuilderBoth search components were enhanced with the new filters:
-
PropertyList (
app/Http/Livewire/PropertyList.php)- Added filter properties
- Updated query logic to apply new filters
- Added queryString parameters for URL persistence
-
AdvancedPropertySearch (
app/Http/Livewire/AdvancedPropertySearch.php)- Added filter properties
- Updated query logic with conditional application
- Added queryString parameters
Enhanced the advanced search form (resources/views/livewire/advanced-property-search.blade.php) with:
- Energy rating dropdown
- Energy score numeric input
- Walkability score numeric input
- Transit score numeric input
- Bike score numeric input
- Country selection dropdown
- Featured properties checkbox
// Find properties with energy rating A or B and score > 70
Property::energyRating('A')
->minEnergyScore(70)
->get();// Find walkable properties with good transit access
Property::walkabilityScore(75)
->transitScore(70)
->get();// Find featured UK properties that are energy efficient and walkable
Property::featured()
->country('UK')
->energyRating('A')
->walkabilityScore(80)
->priceRange(200000, 500000)
->get();Users can share searches via URL:
/properties/search?energyRating=A&minWalkabilityScore=75&featuredOnly=1&country=UK
Comprehensive unit tests were added to tests/Unit/PropertyTest.php:
test_energy_rating_scope()- Tests energy rating filteringtest_min_energy_score_scope()- Tests minimum energy score filteringtest_walkability_score_scope()- Tests walkability score filteringtest_transit_score_scope()- Tests transit score filteringtest_bike_score_scope()- Tests bike score filteringtest_featured_scope()- Tests featured properties filteringtest_country_scope()- Tests country filtering
Each test validates that the scope correctly filters properties based on the criteria.
All filter fields already existed in the database schema:
| Field | Type | Nullable | Migration |
|---|---|---|---|
| energy_rating | string | Yes | 2023_12_01_000001_create_properties.php |
| energy_score | integer | Yes | 2023_12_01_000001_create_properties.php |
| walkability_score | tinyInteger | Yes | 2024_03_15_000000_add_walkability_scores_to_properties_table.php |
| transit_score | tinyInteger | Yes | 2024_03_15_000000_add_walkability_scores_to_properties_table.php |
| bike_score | tinyInteger | Yes | 2024_03_15_000000_add_walkability_scores_to_properties_table.php |
| is_featured | boolean | No | 2023_12_01_000001_create_properties.php |
| country | string | Yes | 2023_12_01_000001_create_properties.php |
No database migrations were required - all fields were already present.
- Enhanced User Experience: Users can now filter properties based on sustainability and lifestyle factors
- Better Property Discovery: More granular search options help users find properties that match their specific needs
- SEO-Friendly: URL query strings allow search parameters to be shared and bookmarked
- Minimal Changes: Implementation leveraged existing database fields and followed established patterns
- Fully Tested: All new scopes have unit test coverage
- Performance: Scopes use efficient database queries with proper indexing considerations
Potential improvements for future iterations:
- Add range sliders for score inputs (UX improvement)
- Display score badges on property cards
- Add sorting by walkability/transit/bike scores
- Implement smart home features filter (JSON field)
- Add energy rating to property cards
- Create saved search functionality for filter combinations
- Add filter analytics to track popular search criteria
All changes are backward compatible:
- New filters are optional
- Default values maintain existing behavior
- Existing queries continue to work unchanged
- No breaking changes to API or data structures
The enhanced search filters provide users with powerful new ways to discover properties that match their sustainability and lifestyle preferences. The implementation follows Laravel best practices, maintains code quality, and includes comprehensive test coverage.