Dear Stackoverflow team! i want to make the search condition with form like picture attachment. i want to store the select box value after form submit to search with multiple condition. so could the the team help make solution for it. below is my model filter condition, it's laravel code
public function scopeFilterInProfile($query, Request $request)
{
$query = Property::where('user_id',auth()->user()->id)
->published()
->expired();
if ($request->input('category')) {
$query->where('parent_id', $request->input('category'));
}
if ($request->input('location')) {
$query->where('province_id', '=', $request->input('location'));
}
if ($request->input('search')) {
$query->where('title', 'LIKE', '%'.$request->input('search').'%');
}
if ($request->input('from_price') && $request->input('to_price')) {
$query->whereBetween('price', [$request->input('from_price'),$request->input('to_price')]);
}
if ($request->input('sort')) {
switch ($request->input('sort')){
case 'posted_date_desc':
$query->orderBy('created_at', 'DESC');
break;
case 'posted_date_asc':
$query->orderBy('created_at', 'ASC');
break;
case 'renew_date_desc':
$query->orderBy('renew_date', 'DESC');
break;
case 'renew_date_asc':
$query->orderBy('renew_date', 'ASC');
break;
case 'price_desc':
$query->orderBy('price', 'DESC');
break;
case 'price_asc':
$query->orderBy('price', 'ASC');
break;
default:
$query->orderBy('posted_date_desc', 'DESC');
}
}
return $query;
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Ns9QKo
via IFTTT
Aucun commentaire:
Enregistrer un commentaire