basic views for users added

This commit is contained in:
s416422 2019-12-01 23:36:12 +01:00
parent e748ade496
commit 98951bc76d
23 changed files with 802 additions and 84 deletions

View File

@ -4,9 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use App\Subject;
use App\Room;
use App\Classes;
use App\Attendance;

View File

@ -4,11 +4,9 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use App\Subject;
use App\Room;
use App\Classes;
use App\Attendance;
class AdminClassesController extends Controller
{

View File

@ -4,11 +4,11 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use App\Subject;
use App\Room;
use App\Classes;
use App\Attendance;
class AdminSubjectsController extends Controller
{

View File

@ -0,0 +1,53 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Subject;
use App\Classes;
use App\Attendance;
class UserAttendancesController extends Controller
{
public function index($user_id, $groupBy)
{
$subjects = Subject::where('user_id', $user_id)->get();
$subjects_ids = $subjects->pluck('id')->toArray();
$classes = Classes::whereIn('subject_id', $subjects_ids)->get();
$classes_ids = $classes->pluck('id')->toArray();
$attendances = Attendance::whereIn('classes_id', $classes_ids)->get();
$attendances_grouped = $attendances->groupBy($groupBy);
return view('user.user_attendances', ['attendances' => $attendances, 'attendances_grouped' => $attendances_grouped, 'classes' => $classes, 'grouped_by' => $groupBy]);
}
public function add_attendance($user_id, Request $request)
{
$classes_id = $request->input('classes_id');
$student_id_number = $request->input('student_id');
$student_name = $request->input('student_name');
$student_surname = $request->input('student_surname');
$seat_number = $request->input('seat_number');
Attendance::create([
'classes_id' => $classes_id,
'student_id_number' => $student_id_number,
'student_name' => $student_name,
'student_surname' => $student_surname,
'seat_number' => $seat_number,
]);
return redirect(route('user_attendances', [$user_id, 'classes_id']));
}
public function delete_attendance($user_id, $attendance_id, $groupBy)
{
Attendance::find($attendance_id)->delete();
return redirect(route('user_attendances', [$user_id, $groupBy]));
}
public function edit_attendance($user_id, $attendance_id, $groupBy)
{
Attendance::find($attendance_id);
return redirect(route('user_attendances', [$user_id, $groupBy]));
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Subject;
use App\Classes;
class UserClassesController extends Controller
{
public function index($user_id, $groupBy)
{
$subjects = Subject::where('user_id', $user_id)->get();
$subjects_ids = $subjects->pluck('id')->toArray();
$classes = Classes::whereIn('subject_id', $subjects_ids)->get();
$classes_grouped = $classes->groupBy($groupBy);
return view('user.user_classes', ['classes' => $classes, 'classes_grouped' => $classes_grouped, 'subjects' => $subjects, 'grouped_by' => $groupBy]);
}
public function add_classes($user_id, Request $request)
{
$subject_id = $request->input('subject_id');
$date = $request->input('date');
Classes::create([
'subject_id' => $subject_id,
'date' => $date
]);
return redirect(route('user_classes', [$user_id, 'name']));
}
public function delete_classes($user_id, $classes_id, $groupBy)
{
Classes::find($classes_id)->delete();
return redirect(route('user_classes', [$user_id, $groupBy]));
}
public function edit_classes($user_id, $classes_id, $groupBy)
{
Classes::find($classes_id);
return redirect(route('user_classes', [$user_id, $groupBy]));
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use App\Subject;
use App\Room;
class UserSubjectsController extends Controller
{
public function index($user_id, $groupBy)
{
$subjects = Subject::where('user_id', $user_id)->get();
$subjects_grouped = $subjects->groupBy($groupBy);
$rooms = Room::all();
$weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
$types = ['Lecture', 'Excercises', 'Labs', 'Other'];
return view('user.user_subjects', ['subjects' => $subjects, 'rooms' => $rooms, 'weekdays' => $weekdays,
'types' => $types, 'subjects_grouped' => $subjects_grouped, 'grouped_by' => $groupBy]);
}
public function add_subject($user_id, Request $request)
{
$name = $request->input('name');
$type = $request->input('type');
$weekday = $request->input('weekday');
$time = $request->input('time');
$room_id = $request->input('room_id');
$user_id_n = $user_id;
Subject::create([
'name' => $name,
'type' => $type,
'weekday'=> $weekday,
'time' => $time,
'room_id' => $room_id,
'user_id' => $user_id_n
]);
return redirect(route('user_subjects', [$user_id, 'weekday']));
}
public function delete_subject($user_id, $subject_id, $groupBy)
{
Subject::find($subject_id)->delete();
return redirect(route('user_subjects', [$user_id, $groupBy]));
}
public function edit_subject($user_id, $subject_id, $groupBy)
{
Subject::find($subject_id);
return redirect(route('user_subjects', [$user_id, $groupBy]));
}
}

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Seeder;
class AttendancesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('attendances')->insert([
'classes_id' => 1,
'student_id_number' => '416010',
'student_name' => 'Joanna',
'student_surname' => 'Paliwoda',
'seat_number' => 13
]);
DB::table('attendances')->insert([
'classes_id' => 1,
'student_id_number' => '416111',
'student_name' => 'Piotr',
'student_surname' => 'Nowak',
'seat_number' => 6
]);
}
}

View File

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Seeder;
class ClassesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('classes')->insert([
'subject_id' => 1,
'date' => '2019-12-02',
]);
DB::table('classes')->insert([
'subject_id' => 2,
'date' => '2019-12-02',
]);
}
}

View File

@ -11,43 +11,13 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
DB::table('users')->insert([
'name' => 'admin',
'surname' => 'main',
'email' => 'admin@admin.com',
'password' => bcrypt('pass1234'),
'is_Admin' => true
]);
DB::table('users')->insert([
'name' => 'test',
'surname' => 'user',
'email' => 'test@test.com',
'password' => bcrypt('test1234'),
'is_Admin' => false
]);
$this->call([
UsersTableSeeder::class,
RoomsTableSeeder::class,
SubjectsTableSeeder::class,
ClassesTableSeeder::class,
AttendancesTableSeeder::class,
]);
DB::table('subjects')->insert([
'name' => 'Systemy Informatyczne UA0',
'type' => 'Excercises',
'weekday' => 'Monday',
'time' => '17:15',
'room_id' => 1,
'user_id' => 2
]);
DB::table('classes')->insert([
'subject_id' => 1,
'date' => '2019-12-02',
]);
DB::table('attendances')->insert([
'classes_id' => 1,
'student_id_number' => '416010',
'student_name' => 'Joanna',
'student_surname' => 'Paliwoda',
'seat_number' => 13
]);
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Seeder;
class SubjectsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('subjects')->insert([
'name' => 'Systemy Informatyczne UA0',
'type' => 'Lecture',
'weekday' => 'Monday',
'time' => '15:30',
'room_id' => 32,
'user_id' => 2
]);
DB::table('subjects')->insert([
'name' => 'Systemy Informatyczne UA0',
'type' => 'Excercises',
'weekday' => 'Monday',
'time' => '17:15',
'room_id' => 7,
'user_id' => 3
]);
}
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Seeder;
class UsersTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->insert([
'name' => 'admin',
'surname' => 'main',
'email' => 'admin@admin.com',
'password' => bcrypt('pass1234'),
'is_Admin' => true
]);
DB::table('users')->insert([
'name' => 'Krzysztof',
'surname' => 'Jassem',
'email' => 'krzysztof@jassem.com',
'password' => bcrypt('pass1234'),
'is_Admin' => false
]);
DB::table('users')->insert([
'name' => 'Jan ',
'surname' => 'Kowalski',
'email' => 'jan@kowalski.com',
'password' => bcrypt('pass1234'),
'is_Admin' => false
]);
}
}

View File

@ -45,7 +45,7 @@
</div>
<div class="form-group row">
<label for="type" class="col-md-4 col-form-label text-md-right">{{ __('Student name') }}</label>
<label for="student_name" class="col-md-4 col-form-label text-md-right">{{ __('Student name') }}</label>
<div class="col-md-6">
<input id="student_name" type="text" class="form-control @error('student_name') is-invalid @enderror" name="student_name" value="{{ old('student_name') }}" autocomplete="student_name">
@ -59,7 +59,7 @@
</div>
<div class="form-group row">
<label for="type" class="col-md-4 col-form-label text-md-right">{{ __('Student surname') }}</label>
<label for="student_surname" class="col-md-4 col-form-label text-md-right">{{ __('Student surname') }}</label>
<div class="col-md-6">
<input id="student_surname" type="text" class="form-control @error('student_surname') is-invalid @enderror" name="student_surname" value="{{ old('student_surname') }}" autocomplete="student_surname">
@ -121,10 +121,10 @@
<td> {{ $attendance->student_surname}}</td>
<td> {{ $attendance->seat_number }} </td>
<td>
<a href="{{ route('admin_delete_attendance', ['attendance_id' => $attendance->id]) }}" name="delete-attendance-btn" class="btn btn-danger"> Delete </a>
<a href="{{ route('admin_delete_attendance', [$attendance->id]) }}" name="delete-attendance-btn" class="btn btn-danger"> Delete </a>
</td>
<td>
<a href="{{ route('admin_edit_attendance', ['attendance_id' => $attendance->id]) }}" name="edit-attendance-btn" class="btn btn-secondary"> Edit </a>
<a href="{{ route('admin_edit_attendance', [$attendance->id]) }}" name="edit-attendance-btn" class="btn btn-secondary"> Edit </a>
</td>
</tr>
@endforeach

View File

@ -68,10 +68,10 @@
{{ 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_id' => $classes_item->id]) }}" name="delete-classes-btn" class="btn btn-danger"> Delete </a>
<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_id' => $classes_item->id]) }}" name="edit-classes-btn" class="btn btn-secondary"> Edit </a>
<a href="{{ route('admin_edit_classes', [$classes_item->id]) }}" name="edit-classes-btn" class="btn btn-secondary"> Edit </a>
</td>
</tr>
@endforeach

View File

@ -76,9 +76,9 @@
<td> {{ $room->capacity }} </td>
<td> {{ $room->arrangement}}</td>
<td>
<a href="{{ route('admin_delete_room', ['room_id' => $room->id]) }}" name="delete-room-btn" class="btn btn-danger"> Delete </a>
<a href="{{ route('admin_delete_room', [$room->id]) }}" name="delete-room-btn" class="btn btn-danger"> Delete </a>
<td>
<a href="{{ route('admin_edit_room', ['room_id' => $room->id]) }}" name="edit-room-btn" class="btn btn-secondary"> Edit </a>
<a href="{{ route('admin_edit_room', [$room->id]) }}" name="edit-room-btn" class="btn btn-secondary"> Edit </a>
</td>
</tr>
@endforeach

View File

@ -147,10 +147,10 @@
<td> {{ $subject->room_id}}</td>
<td> {{ App\Room::find($subject->room_id)->name }} </td>
<td>
<a href="{{ route('admin_delete_subject', ['subject_id' => $subject->id]) }}" name="delete-subject-btn" class="btn btn-danger"> Delete </a>
<a href="{{ route('admin_delete_subject', [$subject->id]) }}" name="delete-subject-btn" class="btn btn-danger"> Delete </a>
</td>
<td>
<a href="{{ route('admin_edit_subject', ['subject_id' => $subject->id]) }}" name="edit-subject-btn" class="btn btn-secondary"> Edit </a>
<a href="{{ route('admin_edit_subject', [$subject->id]) }}" name="edit-subject-btn" class="btn btn-secondary"> Edit </a>
</td>
</tr>
@endforeach

View File

@ -29,7 +29,7 @@
<a href="{{ route('admin_delete_user', [$user->id]) }}" name="delete-user-btn" class="btn btn-danger"> Delete </a>
</td>
<td>
<a href="{{ route('admin_edit_user', ['user_id' => $user->id]) }}" name="edit-user-btn" class="btn btn-secondary"> Edit </a>
<a href="{{ route('admin_edit_user', [$user->id]) }}" name="edit-user-btn" class="btn btn-secondary"> Edit </a>
</td>
@endif
</tr>

View File

@ -1,23 +1,30 @@
@extends('layouts.app')
@section('title') Home @endsection
@section('title') My Home @endsection
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Dashboard</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
You are logged in, {{ Auth::user()->name }}
<div class="container">
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card">
<div class="card-header">Dashboard</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
</div>
<div class="card-body">
<a href="{{ route('user_subjects', [Auth::user()->id, 'weekday']) }}" class="btn btn-primary"> My subjects </a>
<a href="{{ route('user_classes', [Auth::user()->id, 'subject_id']) }}" class="btn btn-primary"> My classes </a>
<a href="{{ route('user_attendances', [Auth::user()->id, 'classes_id']) }}" class="btn btn-primary"> Attendance </a>
</div>
<div class="card-body">
@yield('user_content')
</div>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -24,7 +24,7 @@
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
@CHECK
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>

View File

@ -0,0 +1,159 @@
@extends('home')
@section('title') My Panel - Attendance @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 attendance record </h4>
<form method="POST" action="{{ route('user_add_attendance', [Auth::user()->id]) }}" class="col-md-12">
@csrf
<div class="form-group row">
<label for="classes_id" class="col-md-4 col-form-label text-md-right">{{ __('Classes') }}</label>
<div class="col-md-6">
<select id="classes_id" class="form-control @error('classes_id') is-invalid @enderror" name="classes_id" required>
@foreach ($classes as $classes_item)
<option value="{{ $classes_item->id }}">{{ App\Subject::find(App\Classes::find($classes_item->id)->subject_id)->name }},
{{ App\Subject::find(App\Classes::find($classes_item->id)->subject_id)->type }},
{{ App\Classes::find($classes_item->id)-> date }} {{ App\Subject::find(App\Classes::find($classes_item->id)->subject_id)->time }}
</option>
@endforeach
</select>
@error('classes_id')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="student_id" class="col-md-4 col-form-label text-md-right">{{ __('Student ID') }}</label>
<div class="col-md-6">
<input id="student_id" type="number" class="form-control @error('student_id') is-invalid @enderror" name="student_id" value="{{ old('student_id') }}" required autocomplete="student_id" autofocus>
@error('student_id')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="student_name" class="col-md-4 col-form-label text-md-right">{{ __('Student name') }}</label>
<div class="col-md-6">
<input id="student_name" type="text" class="form-control @error('student_name') is-invalid @enderror" name="student_name" value="{{ old('student_name') }}" autocomplete="student_name">
@error('student_name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="student_surname" class="col-md-4 col-form-label text-md-right">{{ __('Student surname') }}</label>
<div class="col-md-6">
<input id="student_surname" type="text" class="form-control @error('student_surname') is-invalid @enderror" name="student_surname" value="{{ old('student_surname') }}" autocomplete="student_surname">
@error('student_surname')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="seat_number" class="col-md-4 col-form-label text-md-right">{{ __('Seat number') }}</label>
<div class="col-md-6">
<input id="seat_number" type="number" class="form-control @error('seat_number') is-invalid @enderror" name="seat_number" value="{{ old('seat_number') }}" required autocomplete="seat_number" autofocus>
@error('seat_number')
<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 class="card-body">
@if ($attendances->count() > 0)
<h4 class="card-header"> My all attendance records: ({{ $attendances->count() }}) </h4>
<div class="card-body">
<span> Group by: </span>
<a href="{{ route('user_attendances', [Auth::user()->id, 'classes_id']) }}" class="btn btn-primary"> Classes name </a>
<a href="{{ route('user_attendances', [Auth::user()->id, 'student_id_number']) }}" class="btn btn-primary"> Student ID </a>
<a href="{{ route('user_attendances', [Auth::user()->id, 'seat_number']) }}" class="btn btn-primary"> Seat number </a>
</div>
@foreach ($attendances_grouped as $attendances_group_name => $attendances_list)
@if($attendances_group_name)
@if($grouped_by == 'classes_id')
<h5 class="card-title"> {{ App\Subject::find(App\Classes::find($attendances_group_name)->subject_id)->name }},
{{ App\Subject::find(App\Classes::find($attendances_group_name)->subject_id)->type }},
{{ App\Classes::find($attendances_group_name)-> date }} {{ App\Subject::find(App\Classes::find($attendances_group_name)->subject_id)->time }}
({{ $attendances_list->count() }}) </h5>
@else
<h5 class="card-title"> {{ $attendances_group_name }} ({{ $attendances_list->count() }}) </h5>
@endif
@else
<h5 class="card-title"> Other ({{ $attendances_list->count() }})</h5>
@endif
<table class="table table-striped">
<tr class="thead-dark">
<th> Classes name </th>
<th> Student ID </th>
<th> Student name </th>
<th> Student surname </th>
<th> Seat number </th>
<th></th>
<th></th>
</tr>
@foreach ($attendances_list as $attendance)
<tr>
<td> {{ App\Subject::find(App\Classes::find($attendance->classes_id)->subject_id)->name }},
{{ App\Subject::find(App\Classes::find($attendance->classes_id)->subject_id)->type }},
{{ App\Classes::find($attendance->classes_id)-> date }} {{ App\Subject::find(App\Classes::find($attendance->classes_id)->subject_id)->time }} </td>
<td> {{ $attendance->student_id_number }} </td>
<td> {{ $attendance->student_name}}</td>
<td> {{ $attendance->student_surname}}</td>
<td> {{ $attendance->seat_number }} </td>
<td>
<a href="{{ route('user_delete_attendance', [Auth::user()->id, $attendance->id, 'classes_id']) }}" name="delete-attendance-btn" class="btn btn-danger"> Delete </a>
</td>
<td>
<a href="{{ route('user_edit_attendance', [Auth::user()->id, $attendance->id, 'classes_id']) }}" name="edit-attendance-btn" class="btn btn-secondary"> Edit </a>
</td>
</tr>
@endforeach
</table>
@endforeach
@else
<p> No attendance data yet. </p>
@endif
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,103 @@
@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', [Auth::user()->id]) }}">
@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', [Auth::user()->id, 'subject_id']) }}" class="btn btn-primary"> Subject name </a>
<a href="{{ route('user_classes', [Auth::user()->id, '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>
</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_delete_classes', [Auth::user()->id, $classes_item->id, 'subject_id']) }}" name="delete-classes-btn" class="btn btn-danger"> Delete </a>
</td>
<td>
<a href="{{ route('user_edit_classes', [Auth::user()->id, $classes_item->id, 'subject_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

View File

@ -0,0 +1,179 @@
@extends('home')
@section('title') My Panel - Subjects @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 subject </h4>
<form method="POST" action="{{ route('user_add_subject', [Auth::user()->id]) }}">
@csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="type" class="col-md-4 col-form-label text-md-right">{{ __('Type') }}</label>
<div class="col-md-6">
<select id="type" class="form-control @error('type') is-invalid @enderror" name="type">
<option label="-- select type -- "></option>
@foreach ($types as $type)
<option value="{{ $type }}">{{ $type }}</option>
@endforeach
</select>
@error('type')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="weekday" class="col-md-4 col-form-label text-md-right">{{ __('Day of the week') }}</label>
<div class="col-md-6">
<select id="weekday" class="form-control @error('weekday') is-invalid @enderror" name="weekday">
<option label="-- select day of the week -- "></option>
@foreach ($weekdays as $weekday)
<option value="{{ $weekday }}">{{ $weekday }}</option>
@endforeach
</select>
@error('weekday')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="time" class="col-md-4 col-form-label text-md-right">{{ __('Time') }}</label>
<div class="col-md-6">
<input id="time" type="text" class="form-control @error('time') is-invalid @enderror" name="time" value="{{ old('time') }}" autocomplete="time">
@error('time')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="room_id" class="col-md-4 col-form-label text-md-right">{{ __('Room') }}</label>
<div class="col-md-6">
<select id="room_id" class="form-control @error('room_id') is-invalid @enderror" name="room_id" required>
@foreach ($rooms as $room)
<option value="{{ $room->id }}">{{ $room->name }}</option>
@endforeach
</select>
@error('room_id')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="user_id" class="col-md-4 col-form-label text-md-right">{{ __('Instructor') }}</label>
<div class="col-md-6">
<input id="user_id" type="text" class="@error('user_id') is-invalid @enderror form-control-plaintext" name="user_id" value="{{ Auth::user()->name }} {{ Auth::user()->surname }}" readonly>
@error('user_id')
<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 class="card-body">
@if ($subjects->count() > 0)
<h4 class="card-header"> My all subjects: ({{ $subjects->count() }}) </h4>
<div class="card-body">
<span> Group by: </span>
<a href="{{ route('user_subjects', [Auth::user()->id, 'name']) }}" class="btn btn-primary"> Name </a>
<a href="{{ route('user_subjects', [Auth::user()->id, 'type']) }}" class="btn btn-primary"> Type </a>
<a href="{{ route('user_subjects', [Auth::user()->id, 'weekday']) }}" class="btn btn-primary"> Day of the week </a>
<a href="{{ route('user_subjects', [Auth::user()->id, 'time']) }}" class="btn btn-primary"> Time </a>
<a href="{{ route('user_subjects', [Auth::user()->id, 'room_id']) }}" class="btn btn-primary"> Room </a>
</div>
@foreach ($subjects_grouped as $subject_group_name => $subjects_list)
@if($subject_group_name)
@if($grouped_by == 'room_id')
<h5 class="card-title"> {{ App\Room::find($subject_group_name)->name }} ({{ $subjects_list->count() }}) </h5>
@else
<h5 class="card-title"> {{ $subject_group_name }} ({{ $subjects_list->count() }})</h5>
@endif
@else
<h5 class="card-title"> Other ({{ $subjects_list->count() }})</h5>
@endif
<table class="table table-striped">
<tr class="thead-dark">
<th> Name </th>
<th> Type </th>
<th> Day of the week </th>
<th> Time </th>
<th> Instructor </th>
<th> Room </th>
<th></th>
<th></th>
</tr>
@foreach ($subjects_list as $subject)
<tr>
<td> {{ $subject->name }} </td>
<td> {{ $subject->type }} </td>
<td> {{ $subject->weekday }} </td>
<td> {{ $subject->time }} </td>
<td> {{ App\User::find($subject->user_id)->name }} {{ App\User::find($subject->user_id)->surname }}</td>
<td> {{ App\Room::find($subject->room_id)->name }} </td>
<td>
<a href="{{ route('user_delete_subject', [Auth::user()->id, $subject->id, 'weekday']) }}" name="delete-subject-btn" class="btn btn-danger"> Delete </a>
</td>
<td>
<a href="{{ route('user_edit_subject', [Auth::user()->id, $subject->id, 'weekday']) }}" name="edit-subject-btn" class="btn btn-secondary"> Edit </a>
</td>
</tr>
@endforeach
</table>
@endforeach
@else
<p> No subjects yet. </p>
@endif
</div>
</div>
</div>
@endsection

View File

@ -68,7 +68,7 @@
@if (Route::has('login'))
<div class="top-right links">
@auth
<a href="{{ url('/home') }}">Home</a>
<a href="{{ url('/home') }}">My Home</a>
@else
<a href="{{ route('login') }}">Login</a>

View File

@ -26,23 +26,51 @@ Route::group(array('prefix' => 'admin', 'namespace' => 'Admin'), function()
Route::get('/classes', 'AdminClassesController@index')->name('admin_classes');
Route::get('/attendances', 'AdminAttendancesController@index')->name('admin_attendances');
Route::post('/add_user', 'AdminUsersController@add_user')->name('admin_add_user');
Route::post('/add_subject', 'AdminSubjectsController@add_subject')->name('admin_add_subject');
Route::post('/add_room/', 'AdminRoomsController@add_room')->name('admin_add_room');
Route::post('/add_classes/', 'AdminClassesController@add_classes')->name('admin_add_classes');
Route::post('/add_attendance', 'AdminAttendancesController@add_attendance')->name('admin_add_attendance');
Route::group(array('prefix' => 'add'), function() {
Route::post('/user', 'AdminUsersController@add_user')->name('admin_add_user');
Route::post('/subject', 'AdminSubjectsController@add_subject')->name('admin_add_subject');
Route::post('/room', 'AdminRoomsController@add_room')->name('admin_add_room');
Route::post('/classes', 'AdminClassesController@add_classes')->name('admin_add_classes');
Route::post('/attendance', 'AdminAttendancesController@add_attendance')->name('admin_add_attendance');
});
Route::group(array('prefix' => 'delete'), function() {
Route::get('/user/{user_id}', 'AdminUsersController@delete_user')->name('admin_delete_user');
Route::get('/subject/{subject_id}', 'AdminSubjectsController@delete_subject')->name('admin_delete_subject');
Route::get('/room/{room_id}', 'AdminRoomsController@delete_room')->name('admin_delete_room');
Route::get('/classes/{classes_id}', 'AdminClassesController@delete_classes')->name('admin_delete_classes');
Route::get('/attendance/{attendance_id}', 'AdminAttendancesController@delete_attendance')->name('admin_delete_attendance');
});
Route::group(array('prefix' => 'edit'), function() {
Route::get('/user/{user_id}', 'AdminUsersController@edit_user')->name('admin_edit_user');
Route::get('/subject/{subject_id}', 'AdminSubjectsController@edit_subject')->name('admin_edit_subject');
Route::get('/room/{room_id}', 'AdminRoomsController@edit_room')->name('admin_edit_room');
Route::get('/classes/{classes_id}', 'AdminClassesController@edit_classes')->name('admin_edit_classes');
Route::get('/attendance/{attendance_id}', 'AdminAttendancesController@edit_attendance')->name('admin_edit_attendance');
});
});
Route::get('/delete_user/{user_id}', 'AdminUsersController@delete_user')->name('admin_delete_user');
Route::get('/delete_subject/{subject_id}', 'AdminSubjectsController@delete_subject')->name('admin_delete_subject');
Route::get('/delete_room/{room_id}', 'AdminRoomsController@delete_room')->name('admin_delete_room');
Route::get('/delete_classes/{classes_id}', 'AdminClassesController@delete_classes')->name('admin_delete_classes');
Route::get('/delete_attendance/{attendance_id}', 'AdminAttendancesController@delete_attendance')->name('admin_delete_attendance');
Route::group(array('prefix' => 'user/{user_id}', 'namespace' => 'User'), function() {
Route::get('/subjects/{groupBy}', 'UserSubjectsController@index')->name('user_subjects');
Route::get('/classes/{groupBy}', 'UserClassesController@index')->name('user_classes');
Route::get('/attendance/{groupBy}', 'UserAttendancesController@index')->name('user_attendances');
Route::get('/edit_user/{user_id}', 'AdminUsersController@edit_user')->name('admin_edit_user');
Route::get('/edit_subject/{subject_id}', 'AdminSubjectsController@edit_subject')->name('admin_edit_subject');
Route::get('/edit_room/{room_id}', 'AdminRoomsController@edit_room')->name('admin_edit_room');
Route::get('/edit_classes/{classes_id}', 'AdminClassesController@edit_classes')->name('admin_edit_classes');
Route::get('/edit_attendance/{attendance_id}', 'AdminAttendancesController@edit_attendance')->name('admin_edit_attendance');
Route::group(array('prefix' => 'add'), function() {
Route::post('/subject', 'UserSubjectsController@add_subject')->name('user_add_subject');
Route::post('/classes', 'UserClassesController@add_classes')->name('user_add_classes');
Route::post('/attendance', 'UserAttendancesController@add_attendance')->name('user_add_attendance');
});
Route::group(array('prefix' => 'delete'), function() {
Route::get('/subject/{subject_id}/{groupBy}', 'UserSubjectsController@delete_subject')->name('user_delete_subject');
Route::get('/classes/{classes_id}/{groupBy}', 'UserClassesController@delete_classes')->name('user_delete_classes');
Route::get('/attendance/{attendance_id}/{groupBy}', 'UserAttendancesController@delete_attendance')->name('user_delete_attendance');
});
Route::group(array('prefix' => 'edit'), function() {
Route::get('/subject/{subject_id}/{groupBy}', 'UserSubjectsController@edit_subject')->name('user_edit_subject');
Route::get('/classes/{classes_id}/{groupBy}', 'UserClassesController@edit_classes')->name('user_edit_classes');
Route::get('/attendance/{attendance_id}/{groupBy}', 'UserAttendancesController@edit_attendance')->name('user_edit_attendance');
});
});