atcheck/resources/views/admin/admin_classes.blade.php

85 lines
3.8 KiB
PHP

@extends('layouts.adminpanel')
@section('title') Admin Panel - Classes @endsection
@section('admin_content')
<div class="row justify-content-center">
<div class="col-md-12">
<h5> Add new classes </h5>
<form method="POST" action="{{ route('admin_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>
@if ($classes->count() > 0)
<h5> All classes: ({{ $classes->count() }}) </h5>
<table class="table table-striped">
<tr class="thead-dark">
<th>ID</th>
<th> Subject id </th>
<th> Subject name </th>
<th> Date </th>
<th></th>
<th></th>
</tr>
@foreach ($classes as $classes_item)
<tr>
<td> {{ $classes_item->id }}</td>
<td> {{ $classes_item->subject_id }} </td>
<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('admin_delete_classes', [$classes_item->id]) }}" name="delete-classes-btn" class="btn btn-danger"> Delete </a>
</td>
<td>
<a href="{{ route('admin_edit_classes', [$classes_item->id]) }}" name="edit-classes-btn" class="btn btn-secondary"> Edit </a>
</td>
</tr>
@endforeach
</table>
@else
<p> No classes yet. </p>
@endif
</div>
</div>
@endsection