uawdijnntqw1x1x1
IP : 216.73.216.130
Hostname : it-staging-server
Kernel : Linux it-staging-server 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
home
/
forge
/
stage.sksb.smartcon-survey.com
/
app
/
Helpers
/
LiveWireViewHelper.php
/
/
<?php namespace App\Helpers; use App\Models\Assignment; use App\Models\DeviceGroup; use App\Models\Region; use App\Models\SalesOffice; use App\Models\Segment; use App\Models\State; use App\Models\Topic; use App\Models\Type; use Illuminate\Database\Eloquent\Collection; class LiveWireViewHelper { public static function getTab(string $key): array { foreach (self::getTabs() as $tab) { if ($tab['key'] === $key) { return $tab; } } return []; } public static function getTabs(): array { return [ [ 'key' => '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; } }
/home/forge/stage.sksb.smartcon-survey.com/app/Helpers/LiveWireViewHelper.php