aboutsummaryrefslogtreecommitdiffstats
path: root/resources/views/groups/index.blade.php
blob: 1a58bef5b3241e863ee87046365da9e51ad40847 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@extends('layouts.app')

@section('title', 'Groups - Teacher Journal')

@push('styles')
<link rel="stylesheet" href="{{ asset('css/groups.css') }}">
@endpush

@section('content')
<h1>Groups</h1>
<a href="{{ route('groups.create') }}">Add Group</a>

@if($groups->isEmpty())
    <p>No groups found.</p>
    <a href="{{ route('groups.create') }}">Add your first group</a>
@else
    <table>
        <thead>
            <tr>
                <th>Name</th>
                <th>Teacher</th>
                <th>Students</th>
                <th>Sub Groups</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            @foreach($groups as $group)
                <tr>
                    <td><strong>{{ $group->name }}</strong></td>
                    <td>
                        @if($group->teacher)
                            <a href="{{ route('teachers.show', $group->teacher) }}">
                                {{ $group->teacher->name }} {{ $group->teacher->last_name }}
                            </a>
                        @else
                            No teacher
                        @endif
                    </td>
                    <td>{{ $group->students->count() }}</td>
                    <td>{{ $group->subGroups->count() }}</td>
                    <td>
                        <a href="{{ route('groups.show', $group) }}">View</a>
                        <a href="{{ route('groups.edit', $group) }}">Edit</a>
                        <form action="{{ route('groups.destroy', $group) }}" method="POST" style="display:inline;">
                            @csrf
                            @method('DELETE')
                            <button type="submit" onclick="return confirm('Are you sure?')">Delete</button>
                        </form>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
@endif
@endsection