{{-- SATIŞ KANALI SEÇİCİ — satış sayfalarının üst çubuğunda açılır menü. Kanal = ürün tipi (Kültür Turu, Yurt Dışı, Uçak Bileti…). Liste sayfalarında seçim `product_type_id` filtresi olarak aynı sayfada uygulanır; diğer filtreler (arama, tarih) korunur, sayfa numarası sıfırlanır. Başlangıç ekranında bir kanal seçmek o kanalın satış listesini açar. Kanallar acentede açık olan ürün tipleridir (yeni satış penceresiyle aynı liste); acentede tanım yoksa sistemdeki aktif satış tiplerine düşülür. --}} @php $chAgency = auth()->user()->agency; $chList = $chAgency ? $chAgency->productTypes() ->where('agency_product_types.is_active', true) ->where('product_types.is_active', true) ->saleSubject() ->orderBy('product_types.sort_order') ->get() : collect(); if ($chList->isEmpty()) { $chList = $productTypes ?? collect(); } $chCurrent = request('product_type_id') ? (int) request('product_type_id') : null; $chOnIndex = request()->routeIs('agency.sales.index'); $chKeep = request()->only(['year', 'month', 'period', 'target_type']); $chLink = function ($id) use ($chOnIndex, $chKeep) { if ($chOnIndex) { return $id ? route('agency.sales.index', array_merge($chKeep, ['view' => 'list', 'product_type_id' => $id])) : route('agency.sales.index', $chKeep); } $query = array_merge(request()->except(['page', 'product_type_id', 'product_id']), $id ? ['product_type_id' => $id] : []); return url()->current() . ($query ? '?' . http_build_query($query) : ''); }; $chIcon = fn ($icon) => $icon ? (str_contains($icon, ' ') ? $icon : 'fas ' . $icon) : 'fas fa-cube'; $chItems = collect([['id' => null, 'name' => 'Tümü', 'icon' => 'fas fa-layer-group', 'url' => $chLink(null)]]) ->concat($chList->map(fn ($ch) => [ 'id' => (int) $ch->id, 'name' => $ch->name, 'icon' => $chIcon($ch->icon), 'url' => $chLink($ch->id), ])) ->all(); @endphp @if($chList->count() > 1) @endif