diff --git a/app/Http/Controllers/Admin/AdminAttendancesController.php b/app/Http/Controllers/Admin/AdminAttendancesController.php new file mode 100644 index 0000000..1743f2a --- /dev/null +++ b/app/Http/Controllers/Admin/AdminAttendancesController.php @@ -0,0 +1,50 @@ + $attendances, 'classes' => $classes]); + } + + public function add_attendance(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('admin_attendances')); + } + + public function delete_attendance($attendance_id) + { + Attendance::find($attendance_id)->delete(); + return redirect(route('admin_attendances')); + } + + public function edit_attendance($attendance_id) + { + Attendance::find($attendance_id); + return redirect(route('admin_attendances')); + } +} diff --git a/app/Http/Controllers/Admin/AdminClassesController.php b/app/Http/Controllers/Admin/AdminClassesController.php new file mode 100644 index 0000000..41431b6 --- /dev/null +++ b/app/Http/Controllers/Admin/AdminClassesController.php @@ -0,0 +1,44 @@ + $classes, 'subjects' => $subjects]); + } + + public function add_classes(Request $request) + { + $subject_id = $request->input('subject_id'); + $date = $request->input('date'); + Classes::create([ + 'subject_id' => $subject_id, + 'date' => $date + ]); + return redirect(route('admin_classes')); + } + + public function delete_classes($classes_id) + { + Classes::find($classes_id)->delete(); + return redirect(route('admin_classes')); + } + + public function edit_classes($classes_id) + { + Classes::find($classes_id); + return redirect(route('admin_classes')); + } +} diff --git a/app/Http/Controllers/Admin/AdminPanelController.php b/app/Http/Controllers/Admin/AdminPanelController.php new file mode 100644 index 0000000..19a5c69 --- /dev/null +++ b/app/Http/Controllers/Admin/AdminPanelController.php @@ -0,0 +1,14 @@ + $rooms]); + } + + public function add_room(Request $request) + { + $name = $request->input('name'); + $capacity = $request->input('capacity'); + $arrangement = $request->input('arrangement'); + Room::create([ + 'name' => $name, + 'capacity' => $capacity, + 'arrangement' => $arrangement + ]); + return redirect(route('admin_rooms')); + } + + public function delete_room($room_id) + { + Room::find($room_id)->delete(); + return redirect(route('admin_rooms')); + } + + public function edit_room($room_id) + { + Room::find($room_id); + return redirect(route('admin_rooms')); + } +} diff --git a/app/Http/Controllers/Admin/AdminSubjectsController.php b/app/Http/Controllers/Admin/AdminSubjectsController.php new file mode 100644 index 0000000..d075c2b --- /dev/null +++ b/app/Http/Controllers/Admin/AdminSubjectsController.php @@ -0,0 +1,55 @@ + $subjects, 'users' => $users, 'rooms' => $rooms, 'weekdays' => $weekdays, 'types' => $types]); + } + + public function add_subject(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 = $request->input('user_id'); + Subject::create([ + 'name' => $name, + 'type' => $type, + 'weekday'=> $weekday, + 'time' => $time, + 'room_id' => $room_id, + 'user_id' => $user_id + ]); + return redirect(route('admin_subjects')); + } + + public function delete_subject($subject_id) + { + Subject::find($subject_id)->delete(); + return redirect(route('admin_subjects')); + } + + public function edit_subject($subject_id) + { + Subject::find($subject_id); + return redirect(route('admin_subjects')); + } +} diff --git a/app/Http/Controllers/Admin/AdminUsersController.php b/app/Http/Controllers/Admin/AdminUsersController.php new file mode 100644 index 0000000..8b45ac0 --- /dev/null +++ b/app/Http/Controllers/Admin/AdminUsersController.php @@ -0,0 +1,40 @@ + $users]); + } + + public function add_user(Request $request) + { + $name = $request->input('name'); + $surname = $request->input('surname'); + $id_number = $request->input('id_number'); + return redirect(route('admin_users')); + } + + public function delete_user($user_id) + { + User::find($user_id)->delete(); + return redirect(route('admin_users')); + } + + public function edit_user($user_id) + { + User::find($user_id); + return redirect(route('admin_users')); + } +} diff --git a/app/Http/Controllers/AdminPanelController.php b/app/Http/Controllers/AdminPanelController.php deleted file mode 100644 index afb49f0..0000000 --- a/app/Http/Controllers/AdminPanelController.php +++ /dev/null @@ -1,122 +0,0 @@ - $users]); - } - - public function subjects() - { - $subjects = Subject::all(); - return view('admin.admin_subjects', ['subjects' => $subjects]); - } - - public function rooms() - { - $rooms = Room::all(); - return view('admin.admin_rooms', ['rooms' => $rooms]); - } - - public function classes() - { - $classes = Classes::all(); - return view('admin.admin_classes', ['classes' => $classes]); - } - - public function attendances() - { - $attendances = Attendance::all(); - return view('admin.admin_attendances', ['attendances' => $attendances]); - } - - - - - public function delete_user($user_id) - { - User::find($user_id)->delete(); - return redirect('admin_users'); - } - - public function delete_subject($subject_id) - { - Subject::find($subject_id)->delete(); - return redirect('admin_subjects'); - } - - public function delete_room($room_id) - { - Room::find($room_id)->delete(); - return redirect('admin_rooms'); - } - - public function delete_classes($classes_id) - { - Classes::find($classes_id)->delete(); - return redirect('admin_classes'); - } - - public function delete_attendance($attendance_id) - { - Attendance::find($attendance_id)->delete(); - return redirect('admin_attendances'); - } - - - public function add_user(Request $request) - { - $name = $request->input('name'); - $surname = $request->input('surname'); - $id_number = $request->input('id_number'); - return redirect(route('admin_users')); - } - - public function add_subject(Request $request) - { - $name = $request->input('name'); - $surname = $request->input('surname'); - $id_number = $request->input('id_number'); - return redirect('admin_subjects'); - } - - public function add_room(Request $request) - { - $name = $request->input('name'); - $surname = $request->input('surname'); - $id_number = $request->input('id_number'); - return redirect('admin_rooms'); - } - - public function add_classes(Request $request) - { - $name = $request->input('name'); - $surname = $request->input('surname'); - $id_number = $request->input('id_number'); - return redirect('admin_classes'); - } - - public function add_attendance(Request $request) - { - $name = $request->input('name'); - $surname = $request->input('surname'); - $id_number = $request->input('id_number'); - return redirect('admin_attendances'); - } -} diff --git a/app/Subject.php b/app/Subject.php index 1cc95e7..5e5b8c6 100644 --- a/app/Subject.php +++ b/app/Subject.php @@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model; class Subject extends Model { protected $fillable = [ - 'name', 'type', 'room_id', 'user_id' + 'name', 'type', 'weekday', 'time', 'room_id', 'user_id' ]; } diff --git a/database/migrations/2019_11_26_232020_create_classes_table.php b/database/migrations/2019_11_26_232020_create_classes_table.php index 3465579..c8537a9 100644 --- a/database/migrations/2019_11_26_232020_create_classes_table.php +++ b/database/migrations/2019_11_26_232020_create_classes_table.php @@ -18,7 +18,7 @@ class CreateClassesTable extends Migration $table->integer('subject_id'); $table->date('date'); $table->timestamps(); - $table->foreign('subject_id')->references('id')->on('subjects'); + $table->foreign('subject_id')->references('id')->on('subjects')->onDelete('cascade'); }); } diff --git a/database/migrations/2019_11_26_232906_create_subjects_table.php b/database/migrations/2019_11_26_232906_create_subjects_table.php index 0ee52cf..9177734 100644 --- a/database/migrations/2019_11_26_232906_create_subjects_table.php +++ b/database/migrations/2019_11_26_232906_create_subjects_table.php @@ -17,11 +17,13 @@ class CreateSubjectsTable extends Migration $table->bigIncrements('id'); $table->string('name'); $table->string('type')->nullable(); + $table->string('weekday')->nullable(); + $table->string('time')->nullable(); $table->integer('room_id'); $table->integer('user_id'); $table->timestamps(); - $table->foreign('room_id')->references('id')->on('rooms'); - $table->foreign('user_id')->references('id')->on('users'); + $table->foreign('room_id')->references('id')->on('rooms')->onDelete('cascade'); + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); }); } diff --git a/database/migrations/2019_11_26_232945_create_rooms_table.php b/database/migrations/2019_11_26_232945_create_rooms_table.php index 6db0bbd..2d51310 100644 --- a/database/migrations/2019_11_26_232945_create_rooms_table.php +++ b/database/migrations/2019_11_26_232945_create_rooms_table.php @@ -15,7 +15,7 @@ class CreateRoomsTable extends Migration { Schema::create('rooms', function (Blueprint $table) { $table->bigIncrements('id'); - $table->string('name'); + $table->string('name')->unique(); $table->integer('capacity')->nullable(); $table->string('arrangement')->nullable(); $table->timestamps(); diff --git a/database/migrations/2019_11_26_233012_create_attendances_table.php b/database/migrations/2019_11_26_233012_create_attendances_table.php index 4583468..a851d45 100644 --- a/database/migrations/2019_11_26_233012_create_attendances_table.php +++ b/database/migrations/2019_11_26_233012_create_attendances_table.php @@ -21,7 +21,7 @@ class CreateAttendancesTable extends Migration $table->string('student_surname'); $table->integer('seat_number'); $table->timestamps(); - $table->foreign('classes_id')->references('id')->on('classes'); + $table->foreign('classes_id')->references('id')->on('classes')->onDelete('cascade'); }); } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 9a895dc..ae42e5a 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -18,5 +18,36 @@ class DatabaseSeeder extends Seeder '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([ + RoomsTableSeeder::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/RoomsTableSeeder.php b/database/seeds/RoomsTableSeeder.php new file mode 100644 index 0000000..a4e9e33 --- /dev/null +++ b/database/seeds/RoomsTableSeeder.php @@ -0,0 +1,73 @@ + 'A0-1', 'capacity' => 30), + array('name' => 'A0-11', 'capacity' => 24), + array('name' => 'A0-12', 'capacity' => 24), + array('name' => 'A0-3', 'capacity' => 13), + array('name' => 'A0-5', 'capacity' => 13), + array('name' => 'A1-14/15', 'capacity' => 25), + array('name' => 'A1-16/17', 'capacity' => 25), + array('name' => 'A1-18', 'capacity' => 13), + array('name' => 'A1-20', 'capacity' => 13), + array('name' => 'A1-22/23', 'capacity' => 25), + array('name' => 'A1-24/25', 'capacity' => 25), + array('name' => 'A1-33 (Sala RW)', 'capacity' => 64), + array('name' => 'A2-1', 'capacity' => 24), + array('name' => 'A2-10', 'capacity' => 34), + array('name' => 'A2-11', 'capacity' => 34), + array('name' => 'A2-12', 'capacity' => 34), + array('name' => 'A2-14', 'capacity' => 48), + array('name' => 'A2-19', 'capacity' => 48), + array('name' => 'A2-2', 'capacity' => 34), + array('name' => 'A2-20', 'capacity' => 32), + array('name' => 'A2-21', 'capacity' => 48), + array('name' => 'A2-22', 'capacity' => 48), + array('name' => 'A2-23', 'capacity' => 48), + array('name' => 'A2-24', 'capacity' => 48), + array('name' => 'A2-3', 'capacity' => 24), + array('name' => 'A2-4', 'capacity' => 24), + array('name' => 'A2-5', 'capacity' => 24), + array('name' => 'A2-8', 'capacity' => 24), + array('name' => 'A2-9', 'capacity' => 34), + array('name' => 'Aula A', 'capacity' => 196), + array('name' => 'Aula B', 'capacity' => 117), + array('name' => 'Aula C', 'capacity' => 117), + array('name' => 'B1-06', 'capacity' => 4), + array('name' => 'B1-07/08', 'capacity' => 16), + array('name' => 'B1-37', 'capacity' => 18), + array('name' => 'B1-38', 'capacity' => 12), + array('name' => 'B2-08/09', 'capacity' => 16), + array('name' => 'B2-38', 'capacity' => 15), + array('name' => 'B2-39', 'capacity' => 12), + array('name' => 'B2-44', 'capacity' => 4), + array('name' => 'B3-08/09', 'capacity' => 16), + array('name' => 'B3-38', 'capacity' => 18), + array('name' => 'B3-39', 'capacity' => 18), + array('name' => 'B3-49', 'capacity' => 12), + array('name' => 'C2-3', 'capacity' => 1), + array('name' => 'D-1', 'capacity' => 22), + array('name' => 'D-2', 'capacity' => 21), + array('name' => 'D-3', 'capacity' => 22), + array('name' => 'Klub Profesorski', 'capacity' => '') + ]; + foreach ($rooms as $room) { + DB::table('rooms')->insert([ + 'name' => $room['name'], + 'capacity' => $room['capacity'], + 'arrangement' => '' + ]); + } + } +} diff --git a/resources/views/admin/admin_attendances.blade.php b/resources/views/admin/admin_attendances.blade.php index 891de73..de36200 100644 --- a/resources/views/admin/admin_attendances.blade.php +++ b/resources/views/admin/admin_attendances.blade.php @@ -3,39 +3,135 @@ @section('title') Admin Panel - Attendance @endsection @section('admin_content') -
ID | +Classes id | +Classes name | +Student ID | +Student name | +Student surname | +Seat number | ++ | + | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ID | -Classes id | -Student ID | -Student name | -Student surname | -Seat number | -Creation date | +{{ $attendance->id }} | +{{ $attendance->classes_id }} | +{{ 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 + |
{{ $attendance->id }} | -{{ $attendance->classes_id }} | -{{ $attendance->student_id_number }} | -{{ $attendance->student_name}} | -{{ $attendance->student_surname}} | -{{ $attendance->created_at }} | -- Delete - | -
No attendance data yet.
- @endif -No attendance data yet.
+ @endifID | +Subject id | +Subject name | +Date | ++ | + | ||||
---|---|---|---|---|---|---|---|---|---|
ID | -Subject id | -Date | -Creation date | +{{ $classes_item->id }} | +{{ $classes_item->subject_id }} | +{{ 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 + |
{{ $classes_item->id }} | -{{ $classes_item->subject_id }} | -{{ $classes_item->created_at }} | -- Delete - | -
No classes yet.
- @endif -No classes yet.
+ @endifID | +Name | +Capacity | +Arrangement | ++ | + | |||||
---|---|---|---|---|---|---|---|---|---|---|
ID | -Name | -Capacity | -Arrangement | -Creation date | +{{ $room->id }} | +{{ $room->name }} | +{{ $room->capacity }} | +{{ $room->arrangement}} | ++ Delete + | + Edit + |
{{ $room->id }} | -{{ $room->name }} | -{{ $room->capacity }} | -{{ $room->arrangement}} | -{{ $room->room_id}} | -- Delete - | -
No rooms yet.
- @endif -No rooms yet.
+ @endifID | +Name | +Type | +Day of the week | +Time | +User id | +User name | +Room id | +Room name | ++ | + | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ID | -Name | -Type | -User id | -Room id | -Creation date | +{{ $subject->id }} | +{{ $subject->name }} | +{{ $subject->type }} | +{{ $subject->weekday }} | +{{ $subject->time }} | +{{ $subject->user_id}} | +{{ App\User::find($subject->user_id)->name }} {{ App\User::find($subject->user_id)->surname }} | +{{ $subject->room_id}} | +{{ App\Room::find($subject->room_id)->name }} | ++ Delete + | ++ Edit + |
{{ $subject->id }} | -{{ $subject->name }} | -{{ $subject->type }} | -{{ $subject->user_id}} | -{{ $subject->room_id}} | -{{ $subject->created_at }} | -- Delete - | -
No subjects yet.
- @endif -No subjects yet.
+ @endifID | +Name | +Surname | +Is admin | ++ | + | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ID | -Name | -Surname | -Email verification date | -Is admin | -Creation date | +{{ $user->id }} | +{{ $user->name }} | +{{ $user->surname }} | +{{ $user->email }} | +{{ $user->is_Admin }} | + @if (!$user->is_Admin) ++ Delete + | ++ Edit + | + @endif|
{{ $user->id }} | -{{ $user->name }} | -{{ $user->surname }} | -{{ $user->email }} | -{{ $user->email_verified_at}} | -{{ $user->is_Admin }} | -{{ $user->creatied_at}} | - @if (!$user->is_Admin) -- Delete - | - @endif -
No users yet.
- @endif -No users yet.
+ @endifYou are not allowed to see this page.
- Go somewhere nice - @else -You are not allowed to see this page.
+ Go somewhere nice + @else +