blob: 54c477bd707caff8983132c151d6688f3b4a7f42 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
@extends('layouts.app')
@section('title', 'Students - Teacher Journal')
@push('styles')
<link rel="stylesheet" href="{{ asset('css/students.css') }}">
@endpush
@section('content')
<h1>Students</h1>
<a href="{{ route('students.create') }}">Add Student</a>
<form method="GET" action="{{ route('students.index') }}">
<label for="group_id">Filter by Group</label>
<select name="group_id" id="group_id">
<option value="">All Groups</option>
@foreach($groups as $id => $name)
<option value="{{ $id }}" @selected(request('group_id') == $id)>{{ $name }}</option>
@endforeach
</select>
<button type="submit">Filter</button>
@if(request()->hasAny(['group_id']))
<a href="{{ route('students.index') }}">Clear</a>
@endif
</form>
@if($students->isEmpty())
<p>No students found.</p>
<a href="{{ route('students.create') }}">Add your first student</a>
@else
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Group</th>
<th>Sub Group</th>
<th>Points</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($students as $student)
<tr>
<td><strong>{{ $student->name }} {{ $student->last_name }}</strong></td>
<td>{{ $student->age }}</td>
<td>
@if($student->group)
<a href="{{ route('groups.show', $student->group) }}">{{ $student->group->name }}</a>
@else
-
@endif
</td>
<td>
@if($student->subGroup)
<a href="{{ route('sub-groups.show', $student->subGroup) }}">{{ $student->subGroup->name }}</a>
@else
-
@endif
</td>
<td>{{ $student->points ?? 0 }}</td>
<td>
<a href="{{ route('students.show', $student) }}">View</a>
<a href="{{ route('students.edit', $student) }}">Edit</a>
<form action="{{ route('students.destroy', $student) }}" 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
|