I am not sure what keywords to use to search for this answer, its simple but nothing found.
Model are used for sql queries as far as I know. No logic.
So then what about filters?
For example
function getItems($partnerUserId) {
$param = "";
$params = array();
if ($partnerUserId !== '') {
$param = "AND z.x = ?";
$params[] = $partnerUserId;
}
$sql = "SELECT ...
FROM z
WHERE z.a = 1
$param";
return DB::connection($connection)->select($sql, $params);
}
And in real world example there get much more those statements. Is this how model should be or I should do this logic in controller and then pass filter strings as parameters to the model function?