@extends('layouts.app') @section('title', 'Student Assignments') @section('content') @php $money = fn ($v) => \App\Support\Fmt::money2($v); @endphp

Assign students to routes and stops with transport mode

Student Assignments

@include('partials.flashes')

Routes

@foreach ($routes as $route) @php $active = $selected && $route->id === $selected->id; $total = $routeTotals[$route->id] ?? 0; @endphp
{{ $route->name }} {{ $route->stops->count() }} stops
{{ $total }}
@endforeach
@if (! $selected)
Select a route to view its stops and assigned students.
@else @php $routeTotal = $routeTotals[$selected->id] ?? 0; @endphp

{{ $selected->name }}

{{ $selected->stops->count() }} stops · {{ $selected->vehicle_id ? $selected->vehicle->registration_no.' assigned' : 'no vehicle assigned' }}

{{ $routeTotal }} students
@forelse ($stops as $stop) @php $list = $assignments[$stop->id] ?? collect(); @endphp

{{ $stop->name }}

{{ $money($stop->one_way) }} 1-way · {{ $money($stop->two_way) }} 2-way

{{ $list->count() }} assigned
@forelse ($list as $i => $assignment) @if ($i > 0)
@endif
{{ $assignment->student?->full_name ?: '—' }} {{ $assignment->student?->admission_no }} · {{ $assignment->student?->class_name }} {{ $assignment->student?->stream }}
{{ $assignment->mode }}
@csrf @method('DELETE')
@empty

No students assigned to this stop yet.

@endforelse
@empty

This route has no stops yet.

@endforelse
@endif
@if ($selected && $assignStop)

Assign Students

{{ $assignStop->name }}

@if ($errors->has('students'))

{{ $errors->first('students') }}

@endif
@csrf
Clear
@php $needle = trim((string) $request->input('q', '')); $matchCount = $candidates->count(); $picked = (array) old('students', []); @endphp
{{ strlen($needle) < 2 ? 'Start typing to search' : $matchCount.' match(es)' }} {{ count($picked) }} selected
@if (strlen($needle) < 2)

Search to find students

@elseif ($candidates->isEmpty())

No students match your search.

@else @foreach ($candidates as $candidate) @endforeach @endif
@endif
@endsection