@extends('layouts.student')
@section('title', 'Student Timetable')

@section('content')
<div class="container mt-4">
    <div class="card shadow-sm">
        <div class="card-header bg-primary text-white">
            <h4 class="mb-0">Timetable</h4>
        </div>
        <div class="card-body">
            @if($timetable->isEmpty())
                <div class="alert alert-info">No timetable available.</div>
            @else
                <table class="table table-bordered">
                    <thead class="thead-dark">
                        <tr>
                            <th>Date</th>
                            <th>Time</th>
                            <th>Course Code</th>
                            <th>Course Description</th>
                            <th>Campus</th>
                            <th>Venue</th>
                            <th>Duration</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($timetable as $row)
                            <tr>
                                <td>{{ \Carbon\Carbon::parse($row->time)->format('Y-m-d') }}</td>
                                <td>{{ \Carbon\Carbon::parse($row->time)->format('H:i') }}</td>
                                <td>{{ $row->course_code }}</td>
                                <td>{{ $row->course_description }}</td>
                                <td>{{ $row->campus }}</td>
                                <td>{{ $row->venue }}</td>
                                <td>{{ $row->duration }}</td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            @endif
        </div>
    </div>
</div>
@endsection
