@extends('layouts.app') @section('title', 'Sections') @section('content')
{{-- ============================================================ Page Header ============================================================ --}}

Sections

Manage class sections, capacity, student allocation and academic structure.

@can('sections.view') Export CSV @endcan @can('sections.create') New Section @endcan
{{-- ============================================================ Filters ============================================================ --}}
{{-- Search --}}
{{-- --}}
{{-- Academic Year --}}
{{-- Class --}}
{{-- Status --}}
{{-- Actions --}}
@if( filled(request('search')) || filled(request('academic_year_id')) || filled(request('class_id')) || (request('status') !== null && request('status') !== '') ) @endif
{{-- ============================================================ Active Filters ============================================================ --}} @if( filled(request('search')) || filled(request('academic_year_id')) || filled(request('class_id')) || (request('status') !== null && request('status') !== '') ) @php $selectedAcademicYear = filled(request('academic_year_id')) ? $academicYears->firstWhere('id', (int) request('academic_year_id')) : null; $selectedClass = filled(request('class_id')) ? $schoolClasses->firstWhere('id', (int) request('class_id')) : null; @endphp
Active filters: @if(filled(request('search'))) {{-- --}} {{ request('search') }} @endif @if($selectedAcademicYear) {{ $selectedAcademicYear->name }} @endif @if($selectedClass) {{ $selectedClass->name }} @endif @if(request('status') === '1') Active @elseif(request('status') === '0') Inactive @endif Clear all
@endif {{-- ============================================================ Bulk Actions ============================================================ --}} @can('sections.delete') @endcan {{-- ============================================================ Sections Table ============================================================ --}}
{{-- Table Header --}}

Section List

@if($sections->total() > 0) Showing {{ number_format($sections->firstItem()) }} to {{ number_format($sections->lastItem()) }} of {{ number_format($sections->total()) }} sections. @else No sections available. @endif

@if($sections->total() > 0)
Page {{ $sections->currentPage() }} of {{ $sections->lastPage() }}
@endif
@can('sections.delete') @endcan @forelse($sections as $section) @php $studentCount = (int) ($section->students_count ?? 0); $capacity = (int) $section->capacity; $availableSeats = max( 0, $capacity - $studentCount ); $occupancyPercentage = $capacity > 0 ? min( 100, round(($studentCount / $capacity) * 100) ) : 0; $isFull = $capacity > 0 && $studentCount >= $capacity; @endphp {{-- Checkbox --}} @can('sections.delete') @endcan {{-- Section --}} {{-- Class --}} {{-- Academic Year --}} {{-- Capacity --}} {{-- Occupancy --}} {{-- Available Seats --}} {{-- Status --}} {{-- Actions --}} @empty @endforelse
Section Class Academic Year Capacity Occupancy Available Status Actions
@can('sections.view') {{ $section->name }} @else

{{ $section->name }}

@endcan

{{ $section->code ?: 'No code' }}

@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
@if($section->schoolClass?->academicYear)
{{ $section->schoolClass->academicYear->name }} @if($section->schoolClass->academicYear->is_current) Current @endif
@else @endif

{{ number_format($studentCount) }} / {{ number_format($capacity) }}

Students

{{ $occupancyPercentage }}% @if($isFull) Full @elseif($occupancyPercentage >= 80) Nearly Full @else Available @endif
@if($isFull)
@elseif($occupancyPercentage >= 80)
@else
@endif
@if($availableSeats <= 0) Full @elseif($availableSeats <= 5) {{ number_format($availableSeats) }} @else {{ number_format($availableSeats) }} @endif @if($section->is_active) Active @else Inactive @endif
@can('sections.view') @endcan @can('sections.edit') @endcan @can('sections.delete')
@csrf @method('DELETE')
@endcan
@if( filled(request('search')) || filled(request('academic_year_id')) || filled(request('class_id')) || (request('status') !== null && request('status') !== '') )

No matching sections found

No sections match the current search or filter criteria.

Clear Filters @else

No sections found

Create sections under your classes to organize students and attendance.

@can('sections.create') New Section @endcan @endif
{{-- ======================================================== Pagination ======================================================== --}} @if($sections->hasPages())
{{ $sections->withQueryString()->links() }}
@endif
{{-- ================================================================ Bulk Delete Form ================================================================ --}} @can('sections.delete') @endcan @endsection @push('scripts') @endpush