I am building a dynamic query in eloquent. i matching patterns if pattern doesnt match then i want WHERE 1. Basically my question is how to write WHERE 1 in eloquent
if (preg_match('/pattern/', $request->input('user_search'))) {
$filter="'email','{$request->input('user_search')}'";
} elseif (preg_match('/pattern/', $request->input('user_search'))) {
$filter="'mobile','{$request->input('user_search')}'";
} elseif (preg_match('/pattern/', $request->input('user_search'))) {
$filter="'name','like','%{$request->input('user_search')}%'";
} else {
$filter=' I want WHERE 1 here';
The question how to write WHERE 1
}
$user = User::where($filter)->orderBy('created_at', 'DESC')->paginate(50);
WHERE 1? and what version of Laravel and PHP are you using? also all those "filters" are strings, thewheremethod works on columns and values