芝麻web文件管理V1.00
编辑当前文件:/home/forge/stage.sksb.smartcon-survey.com/app/Helpers/LiveWireViewHelper.php
'region', 'model' => Region::class, 'title' => 'Kundenbezirk', ], [ 'key' => 'state', 'model' => State::class, 'title' => 'Bundesland', ], [ 'key' => 'sales_office', 'model' => SalesOffice::class, 'title' => 'Verkaufsbüro', ], [ 'key' => 'assignment', 'model' => Assignment::class, 'title' => 'Verkäuferzuordnung', ], // [ // 'key' => 'category', // 'model' => Category::class, // 'title' => 'Kundenkategorie' // ], [ 'key' => 'type', 'model' => Type::class, 'title' => 'Kundenart', ], [ 'key' => 'devices', 'model' => DeviceGroup::class, 'title' => 'Gerätezahl', ], [ 'key' => 'segment', 'model' => Segment::class, 'title' => 'Segmentierung', ], ]; } public static function getLabels(string $tab): Collection { return $tab::select('id', 'name')->get(); } public static function addIndexResults(array $results, array $questions): array { $indexResults = []; // merge all question into index foreach ($questions as $key => $question) { foreach ($results[$key] as $value) { if (empty($value)) { continue; } if (isset($indexResults[$value['label']])) { $indexResults[$value['label']]['count'] += $value['count']; $indexResults[$value['label']]['total'] += $value['total']; } else { $indexResults[$value['label']] = [ 'label' => $value['label'], 'count' => $value['count'], 'total' => $value['total'], ]; } } } return array_map(static function ($item) { $item['value'] = round($item['count'] / $item['total'] * 100, 1); return $item; }, $indexResults); } public static function getTabTitle(string $key): string { foreach (self::getTabs() as $tab) { if ($tab['key'] === $key) { return $tab['title']; } } return ''; } public static function mergeQuestions(array $questions, int $topicId): array { $surveyHelper2 = new SurveyJSHelper(Topic::find($topicId)); $questions = array_merge($questions, $surveyHelper2->getQuestions()); // remove duplicates return array_reduce($questions, function ($acc, $current) { if (! in_array($current['name'], array_column($acc, 'name'), true)) { $acc[] = $current; } return $acc; }, []); } public static function cleanGet(array $get): array { $cleanGet = []; foreach ($get as $key => $value) { if ($key === 'group_id') { if ($value === 'Bitte wählen') { continue; } $newKey = str_replace('_id', '', $key); $cleanGet[$newKey] = [$value]; } else { $newKey = str_replace('_id', '', $key); $cleanGet[$newKey] = $value; } } return $cleanGet; } public static function filterToRawSQL(): string { $filtes = self::cleanGet($_GET); if (empty($filtes)) { return ''; } $sql = ''; foreach ($filtes as $key => $value) { $sql .= "`$key` IN (".implode(',', $value).')'; if (array_key_last($filtes) !== $key) { $sql .= ' AND '; } } return $sql; } }