@extends('profile.layout') @section('title', __('Məhsullar')) @section('content') @php $typeLabels = [ 'default' => __('Bio-link'), 'mini_site' => __('Mini-səhifə'), 'menu' => __('Menyu'), 'shop' => __('Mağaza'), ]; $typeBadges = [ 'default' => 'badge-blue', 'mini_site' => 'badge-purple', 'menu' => 'badge-green', 'shop' => 'badge-yellow', ]; // Карта page_id (магазина) → категории для динамического селектора. $shopCats = []; foreach ($shops as $s) { $shopCats[$s->page_id] = $s->categories->map(fn($c) => ['id' => $c->id, 'name' => $c->name])->values()->toArray(); } @endphp

{{ __('Məhsullar') }}

{{ __('Bütün məhsullarınız bir yerdə — hansı səhifəyə aid olduğuna görə qruplaşdırılıb.') }}

@if(!$hasAccess)

{{ __('Bu səhifə tarifinizdə mövcud deyil.') }}

{{ __('Mağaza səhifələri və məhsullar hazırkı tarifinizdə mövcud deyil.') }} @if($unlockPlan){{ __('Bu funksiya') }} «{{ $unlockPlan }}» {{ __('tarifində mövcuddur.') }}@endif

{{ __('Tarifi dəyiş') }}
@else {{-- ============ Добавить товар ============ --}} @if($shopPages->isNotEmpty())

{{ __('Yeni məhsul əlavə et') }}

@if($errors->any())
@foreach($errors->all() as $e)

{{ $e }}

@endforeach
@endif
@csrf
@else

{{ __('Məhsul əlavə etmək üçün əvvəlcə mağaza səhifəsi yaratmalısınız.') }}

{{ __('Tovarlar yalnız mağaza səhifələrinə əlavə oluna bilər.') }}

{{ __('Mağaza yarat') }}
@endif {{-- ============ Категории магазинов ============ --}} @if($shops->isNotEmpty())

{{ __('Kateqoriyalar') }}

@foreach($shops as $shop)
first) style="display:none;" @endif> @include('profile._category_panel', ['owner' => $shop, 'type' => 'shop'])
@endforeach
@endif {{-- ============ Товары по страницам ============ --}} @if($totalProducts === 0)

{{ __('Məhsul yoxdur') }}.

@if($shopPages->isNotEmpty())

{{ __('Yuxarıdakı formadan ilk məhsulu əlavə edin.') }}

@endif
@else {{-- ============ Фильтр и поиск ============ --}}
@foreach($pages as $page) @php $prods = $grouped[$page->id] ?? []; @endphp @if(count($prods))
{{ $page->title }} {{ $typeLabels[$page->type] ?? $page->type }} {{ count($prods) }} {{ __('məhsul') }}
@foreach($prods as $p)
{{-- Display --}}
@if($p->image_url) @else
@endif
{{ $p->name }}
{{ number_format($p->price, 2) }} ₼{{ $p->category ? ' · ' . $p->category->name : '' }}{{ $p->description ? ' · ' . mb_substr($p->description, 0, 60) : '' }}
{{-- Edit form --}} {{-- Actions --}}
@csrf @method('PUT')
@csrf @method('DELETE')
@endforeach
@endif @endforeach {{-- Сироты: товар без привязки к странице (на случай удалённой страницы) --}} @if(!empty($grouped[0]))
{{ __('Səhifəsiz') }} {{ count($grouped[0]) }} {{ __('məhsul') }}
@foreach($grouped[0] as $p)
@if($p->image_url)@endif
{{ $p->name }}
{{ number_format($p->price, 2) }} ₼
@csrf @method('DELETE')
@endforeach
@endif @endif @endif @endsection @push('scripts') @endpush