Answer the question
In order to leave comments, you need to log in
Apply filters to SQL query if any?
PostgreSQL 9.6
Filters, there may be more:
$regionFilter = $request->get('filter_1') ? $request->get('filter_1') : "";
$nameFilter = $request->get('filter_2') ?$request->get('filter_2') : "";
$roleFilter= $request->get('filter_3') ? $request->get('filter_3') : "";
$wonRollGame = Game::select('posts.*' ....)
->join('users', function ($join) use ($nameFilter , $roleFilter) {
$join->on('posts.user_id', '=', 'users.id')
->where('users.name', 'LIKE', '%' . $nameFilter . '%')
->where('users.role', '=', $roleFilter);
})
->join('region', function ($join) use ($regionFilter ) {
$join->on('posts.restriction_id', '=', 'region.id')
->where('region.id', '=', $regionFilter);
})
->first();
if ($published == true)
$query->where('published', '=', 1);
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type double precision: ""
WHERE title IS NULL OR LEN(Title) > 0
Answer the question
In order to leave comments, you need to log in
if ($published == true) {
$query->where('published', '=', 1);
}
$published && $query->where('published', '=', 1);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question