@extends('layout') @section('content') @php $isLogged = auth()->check(); $isTalent = $isLogged && (!empty(auth()->user()->is_talent) || (auth()->user()->role ?? '') === 'talent'); @endphp @if($isLogged && !$isTalent)
@endif
@if($isLogged)
📋 Mulai Sesi Saya {{ $isTalent ? \App\Models\Booking::where('talent_id', auth()->id())->whereNotIn('status', ['completed','cancelled'])->count() : \App\Models\Booking::where('customer_id', auth()->id())->whereNotIn('status', ['completed','cancelled'])->count() }}
@endif @php $loggedIsTalent = auth()->check() && (!empty(auth()->user()->is_talent) || (auth()->user()->role ?? '') === 'talent'); if($loggedIsTalent) { $talentUser = auth()->user(); $ratingsQuery = \App\Models\Booking::where('talent_id', $talentUser->id) ->where('status', 'completed') ->whereNotNull('rating'); $talentUser->total_ratings = $ratingsQuery->count(); $talentUser->average_rating = $talentUser->total_ratings > 0 ? $ratingsQuery->avg('rating') : 0; $displayTalents = collect([$talentUser]); } else { $displayTalents = $talents; } @endphp
@forelse($displayTalents as $talent)
@if($talent->avatar) {{ $talent->name }} @else
{{ strtoupper(substr($talent->name, 0, 1)) }}
@endif
{{ $talent->name }} @php $tLevel = $talent->talent_level ?? 'expert'; $tIcons = ['expert' => '⭐', 'exclusif' => '✨', 'elite' => '👑']; $tBg = ['expert' => 'info', 'exclusif' => 'warning', 'elite' => 'danger']; @endphp {{ $tIcons[$tLevel] ?? '⭐' }} {{ ucfirst($tLevel) }}
@if($talent->gender) {{ $talent->gender === 'male' ? '♂ Pria' : ($talent->gender === 'female' ? '♀ Wanita' : '⊙ Lainnya') }} @endif

{{ $talent->email }}

@if(($talent->total_ratings ?? 0) > 0)

★ {{ number_format($talent->average_rating ?? 0, 1) }}/5 ({{ $talent->total_ratings ?? 0 }} ulasan) @if(!is_null($talent->distance_km)) {{ number_format($talent->distance_km, 2) }} km @endif

@else

Belum ada ulasan @if(!is_null($talent->distance_km)) {{ number_format($talent->distance_km, 2) }} km @endif

@endif @if($talent->services->isNotEmpty())
@php // Load custom prices for this talent $talentCustomPrices = \App\Models\TalentServicePrice::where('talent_id', $talent->id) ->pluck('price', 'service_id') ->toArray(); @endphp @foreach($talent->services as $service) @php // Use custom price if available, otherwise default price $displayPrice = $talentCustomPrices[$service->id] ?? $service->price; @endphp {{ $service->name }} ({{ $displayPrice }} Coin) [{{ ucfirst($service->type) }}] @endforeach
@else

No services available

@endif
@if(!$loggedIsTalent) @endif
@empty

No talents found matching your search.

@endforelse
@if($talents->total() > 0)
{{ $talents->appends(request()->query())->links() }}
@endif @if($isTalent)
Layanan Anda
{{-- List of services with active/inactive toggle --}} @php $allServices = \App\Models\Service::all(); $userServiceIds = auth()->user()->services->pluck('id')->toArray(); $talentLevel = auth()->user()->talent_level ?? 'expert'; $canChangePrices = in_array($talentLevel, ['elite', 'exclusif']); // Load custom prices for this talent $customPrices = \App\Models\TalentServicePrice::where('talent_id', auth()->id()) ->pluck('price', 'service_id') ->toArray(); @endphp
@csrf
@if($canChangePrices) @endif @forelse($allServices as $service) @if($canChangePrices) @endif @empty @endforelse
Layanan Type Harga StatusAksi
{{ $service->name }} {{ ucfirst($service->type) }} @php $displayPrice = $customPrices[$service->id] ?? $service->price; $isCustom = isset($customPrices[$service->id]); @endphp {{ $displayPrice }} Coin @if($isCustom) Custom @endif
id, $userServiceIds)) checked @endif>
@if(in_array($service->id, $userServiceIds)) @else - @endif
Belum ada layanan tersedia.
@if($canChangePrices)
Level {{ ucfirst($talentLevel) }}: Anda dapat mengubah harga layanan Anda.
@endif
@endif @if($isTalent) @php $talentReviews = \App\Models\Booking::where('talent_id', auth()->user()->id) ->where('status', 'completed') ->whereNotNull('rating') ->with('customer', 'service') ->latest() ->get(); $avgRating = $talentReviews->count() > 0 ? $talentReviews->avg('rating') : 0; @endphp
Ulasan Pelanggan @if($talentReviews->count() > 0) {{ $talentReviews->count() }} ulasan @endif
@if($talentReviews->count() > 0)
★

{{ number_format($avgRating, 1) }}/5

Berdasarkan {{ $talentReviews->count() }} ulasan
@foreach($talentReviews->take(5) as $review)
@if($review->customer->avatar) {{ $review->customer->name }} @else {{ $review->customer->name }} @endif

{{ $review->customer->name }}

{{ $review->service->name }}
{{ $review->updated_at->format('d M Y') }}
@for($i = 0; $i < 5; $i++) {{ $i < $review->rating ? '★' : '☆' }} @endfor {{ $review->rating }}/5
@if($review->review)

{{ $review->review }}

@endif
@endforeach
@if($talentReviews->count() > 5)
{{ $talentReviews->count() - 5 }} ulasan lagi tidak ditampilkan di sini.
@endif @else

Belum ada ulasan dari pelanggan.

Ulasan akan muncul setelah pelanggan menyelesaikan booking dan memberikan rating.
@endif
@endif @endsection