@extends('layouts.app') @section('title', $section->name) @section('content') @php $studentsCount = (int) ($section->students_count ?? 0); $teacherAssignmentsCount = (int) ($section->teacher_assignments_count ?? 0); $attendancesCount = (int) ($section->attendances_count ?? 0); $capacity = (int) $section->capacity; $availableSeats = max( 0, $capacity - $studentsCount ); $occupancyPercentage = $capacity > 0 ? min( 100, round(($studentsCount / $capacity) * 100) ) : 0; $isFull = $capacity > 0 && $studentsCount >= $capacity; $isNearlyFull = ! $isFull && $occupancyPercentage >= 80; $hasRelatedRecords = $studentsCount > 0 || $teacherAssignmentsCount > 0 || $attendancesCount > 0; @endphp
{{-- ============================================================ Page Header ============================================================ --}}

{{ $section->name }}

@if($section->code) {{ $section->code }} @endif @if($section->is_active) Active @else Inactive @endif

@if($section->schoolClass) {{ $section->schoolClass->name }} @if($section->schoolClass->academicYear) · {{ $section->schoolClass->academicYear->name }} @endif @else Section information and academic configuration. @endif

{{-- ======================================================== Header Actions ======================================================== --}}
All Sections @can('sections.edit') Edit Section @endcan
{{-- ============================================================ Summary Cards ============================================================ --}}
{{-- Students --}}

Students

{{ number_format($studentsCount) }}

{{-- Capacity --}}

Capacity

{{ number_format($capacity) }}

{{-- Available Seats --}}

Available Seats

{{ number_format($availableSeats) }}

{{-- Occupancy --}}

Occupancy

{{ $occupancyPercentage }}%

{{-- ============================================================ Main Information ============================================================ --}}
{{-- ======================================================== Section Information ======================================================== --}}

Section Information

General section details and configuration.

{{-- Section Name --}}
Section Name
{{ $section->name }}
{{-- Code --}}
Section Code
{{ $section->code ?: '—' }}
{{-- Class --}}
Class
@if($section->schoolClass)
@can('school-classes.view') {{ $section->schoolClass->name }} @else {{ $section->schoolClass->name }} @endcan @if($section->schoolClass->code) {{ $section->schoolClass->code }} @endif
@else @endif
{{-- Academic Year --}}
Academic Year
@if($section->schoolClass?->academicYear)
{{ $section->schoolClass->academicYear->name }} @if($section->schoolClass->academicYear->is_current) Current @endif
@else @endif
{{-- Capacity --}}
Student Capacity
{{ number_format($capacity) }} students
{{-- Display Order --}}
Display Order
{{ number_format($section->display_order) }}
{{-- Status --}}
Status
@if($section->is_active) Active @else Inactive @endif
{{-- Record ID --}}
Record ID
#{{ $section->id }}
{{-- Description --}}

Description

@if($section->description)

{{ $section->description }}

@else

No description has been added for this section.

@endif
{{-- ======================================================== Occupancy ======================================================== --}}

Section Occupancy

Current student allocation and capacity.

{{-- Occupancy Header --}}

Occupied

{{ $occupancyPercentage }}%

@if($isFull) Full @elseif($isNearlyFull) Nearly Full @else Available @endif
{{-- Progress --}}
{{ number_format($studentsCount) }} students {{ number_format($capacity) }} capacity
{{-- Occupancy Stats --}}

Occupied

{{ number_format($studentsCount) }}

Available

{{ number_format($availableSeats) }}

{{-- Status Message --}}
@if($isFull)

Section is full

No additional seats are currently available.

@elseif($isNearlyFull)

Section is nearly full

Only {{ number_format($availableSeats) }} seat(s) remain available.

@else

Seats available

{{ number_format($availableSeats) }} seat(s) remain available in this section.

@endif
{{-- ============================================================ Academic Placement ============================================================ --}}

Academic Placement

Class and academic year associated with this section.

{{-- Class --}}

School Class

@if($section->schoolClass)

{{ $section->schoolClass->name }}

@if(!$section->schoolClass->is_active) Inactive @endif
@if($section->schoolClass->code)

Code: {{ $section->schoolClass->code }}

@endif @can('school-classes.view') View Class @endcan @else

No class information available.

@endif
{{-- Academic Year --}}

Academic Year

@if($section->schoolClass?->academicYear)

{{ $section->schoolClass->academicYear->name }}

@if($section->schoolClass->academicYear->is_current) Current @endif @if(!$section->schoolClass->academicYear->is_active) Inactive @endif
@if( $section->schoolClass->academicYear->start_date && $section->schoolClass->academicYear->end_date )

{{ $section->schoolClass->academicYear->start_date->format('d M Y') }} – {{ $section->schoolClass->academicYear->end_date->format('d M Y') }}

@endif @can('academic-years.view') View Academic Year @endcan @else

No academic year information available.

@endif
{{-- ============================================================ Related Records ============================================================ --}}

Related Records

Records and activities currently connected to this section.

{{-- Students --}}
{{ number_format($studentsCount) }}

Students

Students currently assigned to this section.

@can('students.view') View Students @endcan
{{-- Teacher Assignments --}}
{{ number_format($teacherAssignmentsCount) }}

Teacher Assignments

Teacher assignments connected to this section.

@can('teacher-assignments.view') View Assignments @endcan
{{-- Attendance --}}
{{ number_format($attendancesCount) }}

Attendance Records

Student attendance records associated with this section.

@can('attendance.view') View Attendance @endcan
{{-- ============================================================ Record Information + Management ============================================================ --}}
{{-- ======================================================== Record Information ======================================================== --}}

Record Information

System information for this section.

{{-- ID --}}
Record ID
#{{ $section->id }}
{{-- Created --}}
Created
{{ $section->created_at?->format('d M Y, h:i A') ?? '—' }}
{{-- Updated --}}
Last Updated
{{ $section->updated_at?->format('d M Y, h:i A') ?? '—' }}
{{-- ======================================================== Record Management ======================================================== --}}

Record Management

Update or remove this section.

{{-- Edit --}} @can('sections.edit')

Edit Section

Update class placement, capacity, status or section information.

@endcan {{-- Delete --}} @can('sections.delete') @if(!$hasRelatedRecords)
@csrf @method('DELETE')
@else

Section protected from deletion

This section contains related students, teacher assignments or attendance records and cannot be deleted safely.

@if($section->is_active) @can('sections.edit') Set Section Inactive @endcan @endif
@endif @endcan
@endsection @push('scripts') @endpush