$type, ['airline_id', '=', null] ]; if($ref_class) { $where['ref_class'] = $ref_class; } $expenses = $this->findWhere($where); if($airline_id) { $where = [ 'type' => $type, 'airline_id' => $airline_id ]; if ($ref_class) { $where['ref_class'] = $ref_class; } $airline_expenses = $this->findWhere($where); $expenses = $expenses->concat($airline_expenses); } return $expenses; } }