diff --git a/app/Http/Controllers/Admin/AdminAttendancesController.php b/app/Http/Controllers/Admin/AdminAttendancesController.php index 1743f2a..bb2def8 100644 --- a/app/Http/Controllers/Admin/AdminAttendancesController.php +++ b/app/Http/Controllers/Admin/AdminAttendancesController.php @@ -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; diff --git a/app/Http/Controllers/Admin/AdminClassesController.php b/app/Http/Controllers/Admin/AdminClassesController.php index 41431b6..8885d39 100644 --- a/app/Http/Controllers/Admin/AdminClassesController.php +++ b/app/Http/Controllers/Admin/AdminClassesController.php @@ -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 { diff --git a/app/Http/Controllers/Admin/AdminSubjectsController.php b/app/Http/Controllers/Admin/AdminSubjectsController.php index d075c2b..13b8191 100644 --- a/app/Http/Controllers/Admin/AdminSubjectsController.php +++ b/app/Http/Controllers/Admin/AdminSubjectsController.php @@ -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 { diff --git a/app/Http/Controllers/User/UserAttendancesController.php b/app/Http/Controllers/User/UserAttendancesController.php new file mode 100644 index 0000000..3eb9c73 --- /dev/null +++ b/app/Http/Controllers/User/UserAttendancesController.php @@ -0,0 +1,53 @@ +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])); + } +} diff --git a/app/Http/Controllers/User/UserClassesController.php b/app/Http/Controllers/User/UserClassesController.php new file mode 100644 index 0000000..874fa99 --- /dev/null +++ b/app/Http/Controllers/User/UserClassesController.php @@ -0,0 +1,44 @@ +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])); + } +} diff --git a/app/Http/Controllers/User/UserSubjectsController.php b/app/Http/Controllers/User/UserSubjectsController.php new file mode 100644 index 0000000..02431a5 --- /dev/null +++ b/app/Http/Controllers/User/UserSubjectsController.php @@ -0,0 +1,55 @@ +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])); + } +} diff --git a/database/seeds/AttendancesTableSeeder.php b/database/seeds/AttendancesTableSeeder.php new file mode 100644 index 0000000..5d18782 --- /dev/null +++ b/database/seeds/AttendancesTableSeeder.php @@ -0,0 +1,30 @@ +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 + ]); + } +} diff --git a/database/seeds/ClassesTableSeeder.php b/database/seeds/ClassesTableSeeder.php new file mode 100644 index 0000000..cb2d9a3 --- /dev/null +++ b/database/seeds/ClassesTableSeeder.php @@ -0,0 +1,24 @@ +insert([ + 'subject_id' => 1, + 'date' => '2019-12-02', + ]); + + DB::table('classes')->insert([ + 'subject_id' => 2, + 'date' => '2019-12-02', + ]); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index ae42e5a..ae23538 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -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 - ]); } } diff --git a/database/seeds/SubjectsTableSeeder.php b/database/seeds/SubjectsTableSeeder.php new file mode 100644 index 0000000..c4dc0ca --- /dev/null +++ b/database/seeds/SubjectsTableSeeder.php @@ -0,0 +1,32 @@ +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 + ]); + } +} diff --git a/database/seeds/UsersTableSeeder.php b/database/seeds/UsersTableSeeder.php new file mode 100644 index 0000000..677677a --- /dev/null +++ b/database/seeds/UsersTableSeeder.php @@ -0,0 +1,38 @@ +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 + ]); + } +} diff --git a/resources/views/admin/admin_attendances.blade.php b/resources/views/admin/admin_attendances.blade.php index de36200..f745dbf 100644 --- a/resources/views/admin/admin_attendances.blade.php +++ b/resources/views/admin/admin_attendances.blade.php @@ -45,7 +45,7 @@
- +
@@ -59,7 +59,7 @@
- +
@@ -121,10 +121,10 @@ {{ $attendance->student_surname}} {{ $attendance->seat_number }} - Delete + Delete - Edit + Edit @endforeach diff --git a/resources/views/admin/admin_classes.blade.php b/resources/views/admin/admin_classes.blade.php index 33f690b..0a6d1e7 100644 --- a/resources/views/admin/admin_classes.blade.php +++ b/resources/views/admin/admin_classes.blade.php @@ -68,10 +68,10 @@ {{ App\Subject::find($classes_item->subject_id)->weekday }} {{ App\Subject::find($classes_item->subject_id)->time }} {{ $classes_item->date }} - Delete + Delete - Edit + Edit @endforeach diff --git a/resources/views/admin/admin_rooms.blade.php b/resources/views/admin/admin_rooms.blade.php index 44356db..0745014 100644 --- a/resources/views/admin/admin_rooms.blade.php +++ b/resources/views/admin/admin_rooms.blade.php @@ -76,9 +76,9 @@ {{ $room->capacity }} {{ $room->arrangement}} - Delete + Delete - Edit + Edit @endforeach diff --git a/resources/views/admin/admin_subjects.blade.php b/resources/views/admin/admin_subjects.blade.php index 363009e..3c0cfe8 100644 --- a/resources/views/admin/admin_subjects.blade.php +++ b/resources/views/admin/admin_subjects.blade.php @@ -147,10 +147,10 @@ {{ $subject->room_id}} {{ App\Room::find($subject->room_id)->name }} - Delete + Delete - Edit + Edit @endforeach diff --git a/resources/views/admin/admin_users.blade.php b/resources/views/admin/admin_users.blade.php index d571210..ae47869 100644 --- a/resources/views/admin/admin_users.blade.php +++ b/resources/views/admin/admin_users.blade.php @@ -29,7 +29,7 @@ Delete - Edit + Edit @endif diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index ca0e7f7..a724ce3 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -1,23 +1,30 @@ @extends('layouts.app') -@section('title') Home @endsection +@section('title') My Home @endsection @section('content') -
-
-
-
-
Dashboard
-
- @if (session('status')) - - @endif - You are logged in, {{ Auth::user()->name }} +
+
+
+
+
Dashboard
+
+ @if (session('status')) + + @endif +
+ +
+ @yield('user_content') +
-
@endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index d976121..5db957c 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -24,7 +24,7 @@
+ +
+
+ @if ($attendances->count() > 0) +

My all attendance records: ({{ $attendances->count() }})

+ + + + @foreach ($attendances_grouped as $attendances_group_name => $attendances_list) + @if($attendances_group_name) + @if($grouped_by == 'classes_id') +
{{ 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() }})
+ @else +
{{ $attendances_group_name }} ({{ $attendances_list->count() }})
+ @endif + @else +
Other ({{ $attendances_list->count() }})
+ @endif + + + + + + + + + + + + @foreach ($attendances_list as $attendance) + + + + + + + + + + @endforeach +
Classes name Student ID Student name Student surname Seat number
{{ 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 }} {{ $attendance->student_id_number }} {{ $attendance->student_name}} {{ $attendance->student_surname}} {{ $attendance->seat_number }} + Delete + + Edit +
+ @endforeach + @else +

No attendance data yet.

+ @endif +
+
+
+@endsection diff --git a/resources/views/user/user_classes.blade.php b/resources/views/user/user_classes.blade.php new file mode 100644 index 0000000..0056933 --- /dev/null +++ b/resources/views/user/user_classes.blade.php @@ -0,0 +1,103 @@ +@extends('home') + +@section('title') My Panel - Classes @endsection + +@section('user_content') +
+
+
+

Add new classes

+
+ @csrf + +
+ + +
+ + + @error('subject_id') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + @error('date') + + {{ $message }} + + @enderror +
+
+ +
+
+ +
+
+
+
+
+ @if ($classes->count() > 0) +

My all classes: ({{ $classes->count() }})

+ +
+ Group by: + Subject name + Date +
+ + @foreach ($classes_grouped as $classes_group_name => $classes_list) + @if($classes_group_name) + @if($grouped_by == 'subject_id') +
{{ 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() }})
+ @else +
{{ $classes_group_name }} ({{ $classes_list->count() }})
+ @endif + @else +
Other ({{ $classes_list->count() }})
+ @endif + + + + + + + + @foreach ($classes_list as $classes_item) + + + + + + + @endforeach +
Subject name Date
{{ 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 }} {{ $classes_item->date }} + Delete + + Edit +
+ @endforeach + @else +

No classes yet.

+ @endif +
+
+
+@endsection diff --git a/resources/views/user/user_subjects.blade.php b/resources/views/user/user_subjects.blade.php new file mode 100644 index 0000000..f5ef05d --- /dev/null +++ b/resources/views/user/user_subjects.blade.php @@ -0,0 +1,179 @@ +@extends('home') + +@section('title') My Panel - Subjects @endsection + +@section('user_content') +
+
+
+

Add new subject

+
+ @csrf +
+ + +
+ + + @error('name') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + @error('type') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + + @error('weekday') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + @error('time') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + @error('room_id') + + {{ $message }} + + @enderror +
+
+ +
+ + +
+ + + @error('user_id') + + {{ $message }} + + @enderror +
+
+ +
+
+ +
+
+
+
+
+ @if ($subjects->count() > 0) +

My all subjects: ({{ $subjects->count() }})

+ + + + @foreach ($subjects_grouped as $subject_group_name => $subjects_list) + @if($subject_group_name) + @if($grouped_by == 'room_id') +
{{ App\Room::find($subject_group_name)->name }} ({{ $subjects_list->count() }})
+ @else +
{{ $subject_group_name }} ({{ $subjects_list->count() }})
+ @endif + + @else +
Other ({{ $subjects_list->count() }})
+ @endif + + + + + + + + + + + + @foreach ($subjects_list as $subject) + + + + + + + + + + + @endforeach +
Name Type Day of the week Time Instructor Room
{{ $subject->name }} {{ $subject->type }} {{ $subject->weekday }} {{ $subject->time }} {{ App\User::find($subject->user_id)->name }} {{ App\User::find($subject->user_id)->surname }} {{ App\Room::find($subject->room_id)->name }} + Delete + + Edit +
+ @endforeach + @else +

No subjects yet.

+ @endif +
+
+
+@endsection diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 47a54dd..83a9ae8 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -68,7 +68,7 @@ @if (Route::has('login'))