getQueryParams(); $flag = 'a'; if (array_key_exists('flag', $query)) { $v = (string)$query['flag']; if ($v === '' || strtolower($v) === 'all') { $flag = null; // no filter } else { $flag = $v; } } $model = new CommodityModel(); $rows = $model->getAll($flag); if (!$rows) { return ResponseLib::sendFail('Commodities Not Found', [], 'E_DATABASE')->withStatus(204); } return ResponseLib::sendOk($rows); } }