@extends('layouts.storefront') @section('title', $book->title.' — متجر الكتب') @section('content') @php $rating = (float) $book->average_rating; $defaultFormat = $book->displayedFormat(); $authorNames = $book->authors->pluck('name')->implode('، '); $translatorNames = $book->translators->pluck('name')->implode('، '); $plainDescription = $book->plainDescription(); $previewFormats = $book->formats ->filter(fn (\App\Models\BookFormat $format): bool => $format->format_type->isDigital() && filled($format->sample_file)) ->keyBy(fn (\App\Models\BookFormat $format): string => (string) $format->getKey()); $activePreviewId = $defaultFormat && $previewFormats->has((string) $defaultFormat->getKey()) ? (string) $defaultFormat->getKey() : null; $defaultFormatValues = [ 'pages' => $defaultFormat?->pages, 'narrator' => $defaultFormat?->narrator?->name, 'duration' => $defaultFormat?->humanDuration(), 'fileFormat' => $defaultFormat?->file_format?->label(), 'fileSize' => $defaultFormat?->humanFileSize(), ]; $bookFormatTypes = $book->formats->pluck('format_type')->map->value; $formatSpecs = collect([ ['key' => 'pages', 'label' => 'عدد الصفحات', 'formats' => 'physical'], ['key' => 'narrator', 'label' => 'الراوي', 'formats' => 'audiobook'], ['key' => 'duration', 'label' => 'المدة', 'formats' => 'audiobook'], ['key' => 'fileFormat', 'label' => 'صيغة الملف', 'formats' => 'ebook,audiobook'], ['key' => 'fileSize', 'label' => 'حجم الملف', 'formats' => 'ebook,audiobook'], ])->filter(fn (array $spec): bool => $bookFormatTypes->intersect(explode(',', $spec['formats']))->isNotEmpty()) ->values(); @endphp
غلاف {{ $book->title }}
({{ number_format($rating, 1) }}) {{ $book->reviews_count }} {{ $book->reviews_count === 1 ? 'تقييم' : 'تقييمات' }}

{{ $book->title }}

@if ($authorNames) By: {{ $authorNames }} @endif @if ($book->formats->count() > 1)
@foreach ($book->formats as $index => $format) @endforeach
@endif

{{ $defaultFormat ? number_format($defaultFormat->discountedSellingPrice(), 2) : '—' }} ج.م @if ($defaultFormat && $defaultFormat->hasActiveDiscount()) {{ number_format((float) $defaultFormat->selling_price, 2) }} ج.م @endif

@if ($previewFormats->isNotEmpty()) @endif @if ($plainDescription)

{{ \Illuminate\Support\Str::limit($plainDescription, 220) }}

@endif

التوفر:

@if ($defaultFormat === null) غير متاح حالياً @elseif ($defaultFormat->stock_quantity === null) متاح حالياً @elseif ($defaultFormat->stock_quantity > 0) متوفر ({{ $defaultFormat->stock_quantity }} نسخة) @else نفدت الكمية @endif

المعلومات:

التصنيف:

@if ($book->subcategory)

التصنيف الفرعي:

@endif

دار النشر:

{{ $book->publisher->name }}

اللغة:

{{ $book->language->name }}

سنة النشر:

{{ $book->publication_year }}

الطبعة:

{{ $book->edition_number }}

رقم ISBN:

{{ $book->isbn }}
@if ($translatorNames)

المترجم:

{{ $translatorNames }}
@endif @if ($book->tags->isNotEmpty())

الوسوم:

@foreach ($book->tags as $tag) @endforeach
@endif {{-- Format specifications. Each row names the format types it describes in data-when and the button property holding its value in data-info-key, so the switcher reveals the right row and fills it without a branch per field. --}} @foreach ($formatSpecs as $spec) format_type->value, explode(',', $spec['formats']), true)) hidden @endif>

{{ $spec['label'] }}:

{{ $defaultFormatValues[$spec['key']] ?? '' }}
@endforeach
@if ($plainDescription)

{{ $plainDescription }}

@else

لا يوجد وصف متاح لهذا الكتاب.

@endif
@forelse ($book->reviews()->latest()->limit(5)->get() as $review)
  • صورة القارئ
    ({{ number_format((float) $review->rating, 1) }})

    {{ $review->user?->name ?? 'قارئ' }}

    @if ($review->comment)

    {{ $review->comment }}

    @endif {{ $review->created_at?->diffForHumans() }}
@empty

لا توجد تقييمات لهذا الكتاب بعد.

@endforelse
@if ($relatedBooks->isNotEmpty())

كتب ذات صلة

@foreach ($relatedBooks as $related) @php $relatedPrice = $related->displayedFormat()?->discountedSellingPrice(); @endphp
غلاف {{ $related->title }}
({{ number_format((float) $related->average_rating, 1) }})
  • {{ $relatedPrice !== null ? number_format($relatedPrice, 2).' ج.م' : '—' }}

{{ $related->title }}

@endforeach
@endif
@endsection @push('scripts') @endpush