I have table listings and cities, listings hasOne cities relationship. there are 2 inputs, first input is to look name of listing and second input is to look name of city. Listings table has column name and city_id. Cities table has column id and name.
The goal is to look for listing in city input.
the current query look like this
$listings = Listing::where('name', 'LIKE', '%'. $request->search. '%')->where('%'. $request->location. '%', 'LIKE', function($query){
$query->where(DB::raw('cities.name'));
})->paginate(10);
this give error column unknow
SQLSTATE[42S22]: Column not found: 1054 Unknown column '%city input%' in 'where clause' (SQL: select count(*) as aggregate from
listings
wherename
LIKE %listing input% and%city input%
LIKE (select * where cities.name is null))
any idea to fix this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire