atcheck/resources/views/user/user_classes.blade.php

108 lines
5.6 KiB
PHP

@extends('home')
@section('title') My Panel - Classes @endsection
@section('user_content')
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card-body">
<h4 class="card-header"> Add new classes </h4>
<form method="POST" action="{{ route('user_add_classes') }}">
@csrf
<div class="form-group row">
<label for="subject_id" class="col-md-4 col-form-label text-md-right">{{ __('Subject') }}</label>
<div class="col-md-6">
<select id="subject_id" class="form-control @error('subject_id') is-invalid @enderror" name="subject_id" required>
@foreach ($subjects as $subject)
<option value="{{ $subject->id }}">{{ $subject->name }}, {{ $subject->type }}, {{ $subject->weekday }} {{ $subject->time }}</option>
@endforeach
</select>
@error('subject_id')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="date" class="col-md-4 col-form-label text-md-right">{{ __('Date') }}</label>
<div class="col-md-6">
<input id="date" type="date" class="form-control @error('date') is-invalid @enderror" name="date" value="{{ old('date') }}" autocomplete="date">
@error('date')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Add') }}
</button>
</div>
</div>
</form>
</div>
<div>
@if ($classes->count() > 0)
<h4 class="card-header"> My all classes: ({{ $classes->count() }}) </h4>
<div class="card-body">
<span> Group by: </span>
<a href="{{ route('user_classes', ['subject_id']) }}" class="btn btn-primary"> Subject name </a>
<a href="{{ route('user_classes', ['date']) }}" class="btn btn-primary"> Date </a>
</div>
@foreach ($classes_grouped as $classes_group_name => $classes_list)
@if($classes_group_name)
@if($grouped_by == 'subject_id')
<h5 class="card-title"> {{ App\Subject::find($classes_group_name)->name }}, {{ App\Subject::find($classes_group_name)->type }},
{{ App\Subject::find($classes_group_name)->weekday }} {{ App\Subject::find($classes_group_name)->time }} ({{ $classes_list->count() }}) </h5>
@else
<h5 class="card-title"> {{ $classes_group_name }} ({{ $classes_list->count() }}) </h5>
@endif
@else
<h5 class="card-title"> Other ({{ $classes_list->count() }})</h5>
@endif
<table class="table table-striped">
<tr class="thead-dark">
<th> Subject name </th>
<th> Date </th>
<th></th>
<th></th>
<th></th>
</tr>
@foreach ($classes_list as $classes_item)
<tr>
<td> {{ App\Subject::find($classes_item->subject_id)->name }}, {{ App\Subject::find($classes_item->subject_id)->type }},
{{ App\Subject::find($classes_item->subject_id)->weekday }} {{ App\Subject::find($classes_item->subject_id)->time }}</td>
<td> {{ $classes_item->date }} </td>
<td>
<a href="{{ route('user_start_classes', [$classes_item->id]) }}" name="start-classes-btn" class="btn btn-warning"> Rozpocznij zapisy </a>
</td>
<td>
<a href="{{ route('user_delete_classes', [$classes_item->id]) }}" name="delete-classes-btn" class="btn btn-danger"> Delete </a>
</td>
<td>
<a href="{{ route('user_edit_classes', [$classes_item->id]) }}" name="edit-classes-btn" class="btn btn-secondary"> Edit </a>
</td>
</tr>
@endforeach
</table>
@endforeach
@else
<p> No classes yet. </p>
@endif
</div>
</div>
</div>
@endsection