@extends('layouts.app') @section('title', 'Book Copies') @section('styles') @endsection @section('content')
{{-- ===== Toast Notifications ===== --}}
{{-- ===== Page Header ===== --}}

Book Copies

@if($selectedBook)

Showing copies for: {{ $selectedBook->title }} by {{ $selectedBook->author }}

@else

All book copy batches in the system.

@endif
Back to Books @if($selectedBook) View All @endif
{{-- ===== Filter by Book ===== --}}
{{-- ===== Summary Cards ===== --}} @php $totalBatches = count($copies); $totalStock = $copies->sum('stock'); $availableBatches = $copies->where('is_available', 1)->count(); $usedBatches = $copies->where('is_available', 0)->count(); @endphp
{{ $totalBatches }}
Total Batches
{{ $totalStock }}
Total Stock Available
{{ $availableBatches }}
Active Batches
{{ $usedBatches }}
Depleted Batches
{{-- ===== Book Copies Table ===== --}}
Copy Batches {{ $totalBatches }} record(s)
{{-- Columns required by spec --}} @forelse($copies as $index => $copy) {{-- Dim the row if stock is 0 / unavailable --}} {{-- Thumbnail --}} {{-- Book title + author + ISBN --}} {{-- Book ID --}} {{-- Stock number with colour badge --}} {{-- Available / Depleted --}} {{-- Date added --}} {{-- Actions --}} @empty @endforelse
# Cover Book Title Book ID Stock (Copies) Status Date Added Actions
{{ $index + 1 }} @if($copy->book_cover) Cover @else No img @endif {{ $copy->title }}
{{ $copy->author }}
{{ $copy->isbn }}
#{{ $copy->book_id }} @php $stockClass = $copy->stock >= 5 ? 'badge-stock-ok' : ($copy->stock > 0 ? 'badge-stock-low' : 'badge-stock-zero'); @endphp {{ $copy->stock }} @if($copy->is_available) Available @else Depleted @endif {{ \Carbon\Carbon::parse($copy->date)->format('d M Y') }} {{-- Use copy (decrease stock by 1) --}} {{-- Restore copy (increase stock by 1) --}}
No book copy batches found. @if($bookId)
View all batches @endif
{{-- ===== Legend ===== --}}
  5+ copies     1–4 copies     Depleted (0 copies)
@endsection @section('scripts') @endsection