public function filter($showActiveOnly, $showNotAdded, $showHalfAdded, $showDeclined)
{
$table = $this->db->table(self::TABLE_NAME);
$inArray = $this->getFilterInArray($showActiveOnly, $showNotAdded, $showHalfAdded, $showDeclined);
return empty($inArray) ? $table : $table->where('status', $inArray);
}
private function getFilterInArray($showActiveOnly, $showNotAdded, $showHalfAdded, $showDeclined): array
{
$statuses = [
'dodano' => $showActiveOnly,
'nedodano' => $showNotAdded,
'casdodano' => $showHalfAdded,
'storno' => $showDeclined,
];
return array_filter($statuses, static fn (bool $value): bool => $value);
//return array_filter($statuses, static function(bool $value) {return $value});
}
public function filter($showActiveOnly, $showNotAdded, $showHalfAdded, $showDeclined)
{
$statuses = [
'dodano' => $showActiveOnly,
'nedodano' => $showNotAdded,
'casdodano' => $showHalfAdded,
'storno' => $showDeclined,
];
foreach ($statuses as $status => $addFilter)
{
if ($addFilter)
{
return $this->db->table(self::TABLE_NAME)->where(array('status' => $status));
}
}
return $this->db->table(self::TABLE_NAME);
}
$newRow = $this->db->table(self::TABLE_NAME)->where(array('status' => $status));
public function filter($showActiveOnly, $showNotAdded, $showHalfAdded, $showDeclined)
{
$newRow = [];
$statuses = [
'dodano' => $showActiveOnly,
'nedodano' => $showNotAdded,
'casdodano' => $showHalfAdded,
'storno' => $showDeclined,
];
foreach ($statuses as $status => $addFilter) {
if ($addFilter) {
$newRow[$status] = $this->db->table(self::TABLE_NAME)->where(array('status' => $status));
}
}
return $newRow ?: $this->db->table(self::TABLE_NAME);
}
если то что присылается с приложения в get запросе совпадает с тем что находится в базе данных
Но, возможно, я туплю и редбин выдаёт сразу массив, а не строку