I have a mini search feature. I'm trying to let a landlord find tenants whose set property preferences are equal to or great than the property.
So if the landlord has a property in Dublin with 3 beds, 2 baths.
The search will return all tenants that have specified they want a property with 3 beds or less, and 2 baths or less.
The issue I have is that only county is matching up.
These are the records that match when a tenant specifies they want a Dublin property and the landlord has a property in Dublin.
Property Record of the signed in landlord Property Record
Tenant Preferance record Property Record
This is the code
public function searchresults(){
//Gets all users that are tenants
$tenants = User::where('userType', 'tenant')->first();
//Gets all preferances
$Prefereances = TenantPreferance::all()->first();
//Gets the prefereances that match a tenant id
$pref = $Prefereances::where('user_id', $tenants->id)->first();
//Gets the current signed in users property
$property = PropertyAdvert::where('user_id', Auth::user()->id)->first();
$result = $pref::where(
'county' , $property->county,
'type' , $property->type,
'rent', '<=', $property->rent,
'bedrooms', '>=', $property->bedrooms,
'bathrooms', '>-', $property->bathrooms
);
$users = $result->get();
return view('pages/account/search/results', compact('users'));
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2jrE2X3
via IFTTT
Aucun commentaire:
Enregistrer un commentaire