Admin panel created

This commit is contained in:
s416422 2019-12-01 19:31:49 +01:00
parent c4e649eafc
commit e748ade496
23 changed files with 881 additions and 328 deletions

View File

@ -0,0 +1,50 @@
<?php
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 AdminAttendancesController extends Controller
{
public function index()
{
$attendances = Attendance::all();
$classes = Classes::all();
return view('admin.admin_attendances', ['attendances' => $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'));
}
}

View File

@ -0,0 +1,44 @@
<?php
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
{
public function index()
{
$classes = Classes::all();
$subjects = Subject::all();
return view('admin.admin_classes', ['classes' => $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'));
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
class AdminPanelController extends Controller
{
public function index()
{
return view('layouts.adminpanel');
}
}

View File

@ -0,0 +1,45 @@
<?php
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 AdminRoomsController extends Controller
{
public function index()
{
$rooms = Room::all();
return view('admin.admin_rooms', ['rooms' => $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'));
}
}

View File

@ -0,0 +1,55 @@
<?php
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
{
public function index()
{
$subjects = Subject::all();
$users = User::all();
$rooms = Room::all();
$weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
$types = ['Lecture', 'Excercises', 'Labs', 'Other'];
return view('admin.admin_subjects', ['subjects' => $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'));
}
}

View File

@ -0,0 +1,40 @@
<?php
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 AdminUsersController extends Controller
{
public function index()
{
$users = User::all();
return view('admin.admin_users', ['users' => $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'));
}
}

View File

@ -1,122 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use App\Subject;
use App\Room;
use App\Classes;
use App\Attendance;
class AdminPanelController extends Controller
{
public function index()
{
return view('layouts.adminpanel');
}
public function users()
{
$users = User::all();
return view('admin.admin_users', ['users' => $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');
}
}

View File

@ -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'
];
}

View File

@ -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');
});
}

View File

@ -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');
});
}

View File

@ -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();

View File

@ -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');
});
}

View File

@ -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
]);
}
}

View File

@ -0,0 +1,73 @@
<?php
use Illuminate\Database\Seeder;
class RoomsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$rooms = [
array('name' => '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' => ''
]);
}
}
}

View File

@ -3,31 +3,128 @@
@section('title') Admin Panel - Attendance @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="col-md-12">
<h5> Add new attendance record </h5>
<form method="POST" action="{{ route('admin_add_attendance') }}" 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="type" 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="type" 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>
@if ($attendances->count() > 0)
<h5> All attendance: ({{ $attendances->count() }}) </h5>
<table>
<tr>
<h5> All attendance records: ({{ $attendances->count() }}) </h5>
<table class="table table-striped">
<tr class="thead-dark">
<th>ID</th>
<th> Classes id </th>
<th> Classes name </th>
<th> Student ID </th>
<th> Student name </th>
<th> Student surname </th>
<th> Seat number </th>
<th> Creation date </th>
<th></th>
<th></th>
</tr>
@foreach ($attendances as $attendance)
<tr>
<td> {{ $attendance->id }}</td>
<td> {{ $attendance->classes_id }} </td>
<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->created_at }} </td>
<td> {{ $attendance->seat_number }} </td>
<td>
<a href="{{ route('admin_delete_attendance', ['attendance_id' => $attendance->id]) }}" name="delete-attendance-btn"> Delete </a>
<a href="{{ route('admin_delete_attendance', ['attendance_id' => $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>
</td>
</tr>
@endforeach
@ -37,5 +134,4 @@
@endif
</div>
</div>
</div>
@endsection

View File

@ -3,25 +3,75 @@
@section('title') Admin Panel - Classes @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<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>
<tr>
<table class="table table-striped">
<tr class="thead-dark">
<th>ID</th>
<th> Subject id </th>
<th> Subject name </th>
<th> Date </th>
<th> Creation 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> {{ $classes_item->created_at }} </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_id' => $classes_item->id]) }}" name="delete-classes-btn"> Delete </a>
<a href="{{ route('admin_delete_classes', ['classes_id' => $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>
</td>
</tr>
@endforeach
@ -31,5 +81,4 @@
@endif
</div>
</div>
</div>
@endsection

View File

@ -3,18 +3,71 @@
@section('title') Admin Panel - Rooms @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="col-md-12">
<h5> Add new room </h5>
<form method="POST" action="{{ route('admin_add_room') }}">
@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="capacity" class="col-md-4 col-form-label text-md-right">{{ __('Capacity') }}</label>
<div class="col-md-6">
<input id="capacity" type="number" class="form-control @error('capacity') is-invalid @enderror" name="capacity" value="{{ old('capacity') }}" autocomplete="capacity">
@error('capacity')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="arrangement" class="col-md-4 col-form-label text-md-right">{{ __('Arrangement') }}</label>
<div class="col-md-6">
<input id="arrangement" type="text" class="form-control @error('arrangement') is-invalid @enderror" name="arrangement" value="{{ old('arrangement') }}" autocomplete="arrangement">
@error('arrangement')
<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 ($rooms->count() > 0)
<h5> All rooms: ({{ $rooms->count() }}) </h5>
<table>
<tr>
<table class="table table-striped">
<tr class="thead-dark">
<th>ID</th>
<th> Name </th>
<th> Capacity </th>
<th> Arrangement </th>
<th> Creation date </th>
<th></th>
<th></th>
</tr>
@foreach ($rooms as $room)
<tr>
@ -22,9 +75,10 @@
<td> {{ $room->name }} </td>
<td> {{ $room->capacity }} </td>
<td> {{ $room->arrangement}}</td>
<td> {{ $room->room_id}}</td>
<td>
<a href="{{ route('admin_delete_room', ['room_id' => $room->id]) }}" name="delete-room-btn"> Delete </a>
<a href="{{ route('admin_delete_room', ['room_id' => $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>
</td>
</tr>
@endforeach
@ -34,5 +88,4 @@
@endif
</div>
</div>
</div>
@endsection

View File

@ -3,30 +3,154 @@
@section('title') Admin Panel - Subjects @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="col-md-12">
<h5> Add new subject </h5>
<form method="POST" action="{{ route('admin_add_subject') }}">
@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">{{ __('User') }}</label>
<div class="col-md-6">
<select id="user_id" class="form-control @error('user_id') is-invalid @enderror" name="user_id" required>
@foreach ($users as $user)
<option value="{{ $user->id }}">{{ $user->name }} {{ $user->surname }}</option>
@endforeach
</select>
@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>
@if ($subjects->count() > 0)
<h5> All subjects: ({{ $subjects->count() }}) </h5>
<table>
<tr>
<table class="table table-striped">
<tr class="thead-dark">
<th>ID</th>
<th> Name </th>
<th> Type </th>
<th> Day of the week </th>
<th> Time </th>
<th> User id </th>
<th> User name </th>
<th> Room id </th>
<th> Creation date </th>
<th> Room name </th>
<th></th>
<th></th>
</tr>
@foreach ($subjects as $subject)
<tr>
<td> {{ $subject->id }}</td>
<td> {{ $subject->name }} </td>
<td> {{ $subject->type }} </td>
<td> {{ $subject->weekday }} </td>
<td> {{ $subject->time }} </td>
<td> {{ $subject->user_id}}</td>
<td> {{ App\User::find($subject->user_id)->name }} {{ App\User::find($subject->user_id)->surname }}</td>
<td> {{ $subject->room_id}}</td>
<td> {{ $subject->created_at }} </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"> Delete </a>
<a href="{{ route('admin_delete_subject', ['subject_id' => $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>
</td>
</tr>
@endforeach
@ -36,5 +160,4 @@
@endif
</div>
</div>
</div>
@endsection

View File

@ -3,20 +3,19 @@
@section('title') Admin Panel - Users @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="col-md-12">
@if ($users->count() > 0)
<h5> All users: ({{ $users->count() }}) </h5>
<table>
<tr>
<table class="table table-striped">
<tr class="thead-dark">
<th>ID</th>
<th> Name </th>
<th> Surname </th>
<th> Email </th>
<th> Email verification date </th>
<th> Is admin </th>
<th> Creation date </th>
<th></th>
<th></th>
</tr>
@foreach ($users as $user)
<tr>
@ -24,12 +23,13 @@
<td> {{ $user->name }} </td>
<td> {{ $user->surname }} </td>
<td> {{ $user->email }} </td>
<td> {{ $user->email_verified_at}}</td>
<td> {{ $user->is_Admin }} </td>
<td> {{ $user->creatied_at}}</td>
@if (!$user->is_Admin)
<td>
<a href="{{ route('admin_delete_user', [$user->id]) }}" name="delete-user-btn"> Delete </a>
<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>
</td>
@endif
</tr>
@ -40,5 +40,4 @@
@endif
</div>
</div>
</div>
@endsection

View File

@ -31,7 +31,7 @@
<label for="surname" class="col-md-4 col-form-label text-md-right">{{ __('Surname') }}</label>
<div class="col-md-6">
<input id="surname" type="text" class="form-control @error('surname') is-invalid @enderror" name="surname" value="{{ old('surname') }}" required autocomplete="surname" autofocus>
<input id="surname" type="text" class="form-control @error('surname') is-invalid @enderror" name="surname" value="{{ old('surname') }}" required autocomplete="surname">
@error('name')
<span class="invalid-feedback" role="alert">

View File

@ -3,9 +3,8 @@
@section('title') Admin Panel @endsection
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="col-md-12">
@if (!Auth::user()->is_Admin)
<p> You are not allowed to see this page. </p>
<a href="{{ route('home') }}"> Go somewhere nice </a>
@ -20,11 +19,11 @@
@endif
</div>
<div class="card-body">
<a href="{{ route('admin_users') }}"> Users </a>
<a href="{{ route('admin_subjects') }}"> Subjects </a>
<a href="{{ route('admin_rooms') }}"> Rooms </a>
<a href="{{ route('admin_classes') }}"> Classes </a>
<a href="{{ route('admin_attendances') }}"> Attendances </a>
<a href="{{ route('admin_users') }}" class="btn btn-primary"> Users </a>
<a href="{{ route('admin_subjects') }}" class="btn btn-primary"> Subjects </a>
<a href="{{ route('admin_rooms') }}" class="btn btn-primary"> Rooms </a>
<a href="{{ route('admin_classes') }}" class="btn btn-primary"> Classes </a>
<a href="{{ route('admin_attendances') }}" class="btn btn-primary"> Attendances </a>
</div>
<div class="card-body">
@yield('admin_content')
@ -33,5 +32,4 @@
@endif
</div>
</div>
</div>
@endsection

View File

@ -51,7 +51,7 @@
@else
@if (Auth::user()->is_Admin)
<li class="nav-item">
<a class="nav-link" href="{{ url('/admin') }}">{{ __('Admin panel') }}</a>
<a class="nav-link" href="{{ route('admin') }}">{{ __('Admin panel') }}</a>
</li>
@endif
<li class="nav-item dropdown">
@ -78,7 +78,9 @@
</nav>
<main class="py-4">
<div class="container">
@yield('content')
</div>
</main>
</div>
</body>

View File

@ -14,34 +14,35 @@
Route::get('/', function () {
return view('welcome');
});
Route::get('/admin', function () {
return view('adminpanel');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::get('/admin', 'AdminPanelController@index')->name('admin');
Route::group(array('prefix' => 'admin'), function()
Route::group(array('prefix' => 'admin', 'namespace' => 'Admin'), function()
{
Route::get('/', 'AdminPanelController@index')->name('admin');
Route::get('/users', 'AdminPanelController@users')->name('admin_users');
Route::get('/subjects', 'AdminPanelController@subjects')->name('admin_subjects');
Route::get('/rooms', 'AdminPanelController@rooms')->name('admin_rooms');
Route::get('/classes', 'AdminPanelController@classes')->name('admin_classes');
Route::get('/attendances', 'AdminPanelController@attendances')->name('admin_attendances');
Route::get('/users', 'AdminUsersController@index')->name('admin_users');
Route::get('/subjects', 'AdminSubjectsController@index')->name('admin_subjects');
Route::get('/rooms', 'AdminRoomsController@index')->name('admin_rooms');
Route::get('/classes', 'AdminClassesController@index')->name('admin_classes');
Route::get('/attendances', 'AdminAttendancesController@index')->name('admin_attendances');
Route::get('/delete_user/{user_id}', 'AdminPanelController@delete_user')->name('admin_delete_user');
Route::get('/delete_subject/{subject_id}', 'AdminPanelController@delete_subject')->name('admin_delete_subject');
Route::get('/delete_room/{room_id}', 'AdminPanelController@delete_room')->name('admin_delete_room');
Route::get('/delete_classes/{classes_id}', 'AdminPanelController@delete_classes')->name('admin_delete_classes');
Route::get('/delete_attendance/{attendance_id}', 'AdminPanelController@delete_attendance')->name('admin_delete_attendance');
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::post('/add_user', 'AdminPanelController@add_user')->name('admin_add_user');
Route::post('/add_subject', 'AdminPanelController@dadd_subject')->name('admin_add_subject');
Route::post('/add_room/', 'AdminPanelController@dadd_room')->name('admin_add_room');
Route::post('/add_classes/', 'AdminPanelController@dadd_classes')->name('admin_add_classes');
Route::post('/add_attendance', 'AdminPanelController@add_attendance')->name('admin_add_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::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');
});