Classes model renamed, admin panel templates added

This commit is contained in:
s416422 2019-12-01 00:22:33 +01:00
parent d62e97ac42
commit c4e649eafc
13 changed files with 348 additions and 10 deletions

View File

@ -4,7 +4,7 @@ namespace App;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Class extends Model class Classes extends Model
{ {
protected $fillable = [ protected $fillable = [
'subject_id', 'date' 'subject_id', 'date'

View File

@ -3,6 +3,11 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\User;
use App\Subject;
use App\Room;
use App\Classes;
use App\Attendance;
class AdminPanelController extends Controller class AdminPanelController extends Controller
{ {
@ -10,4 +15,108 @@ class AdminPanelController extends Controller
{ {
return view('layouts.adminpanel'); 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

@ -13,7 +13,7 @@ class CreateRoomsTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::create('room', function (Blueprint $table) { Schema::create('rooms', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->string('name'); $table->string('name');
$table->integer('capacity')->nullable(); $table->integer('capacity')->nullable();

View File

@ -13,7 +13,7 @@ class CreateAttendancesTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::create('attendance', function (Blueprint $table) { Schema::create('attendances', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->integer('classes_id'); $table->integer('classes_id');
$table->integer('student_id_number'); $table->integer('student_id_number');

View File

@ -0,0 +1,41 @@
@extends('layouts.adminpanel')
@section('title') Admin Panel - Attendance @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
@if ($attendances->count() > 0)
<h5> All attendance: ({{ $attendances->count() }}) </h5>
<table>
<tr>
<th>ID</th>
<th> Classes id </th>
<th> Student ID </th>
<th> Student name </th>
<th> Student surname </th>
<th> Seat number </th>
<th> Creation date </th>
</tr>
@foreach ($attendances as $attendance)
<tr>
<td> {{ $attendance->id }}</td>
<td> {{ $attendance->classes_id }} </td>
<td> {{ $attendance->student_id_number }} </td>
<td> {{ $attendance->student_name}}</td>
<td> {{ $attendance->student_surname}}</td>
<td> {{ $attendance->created_at }} </td>
<td>
<a href="{{ route('admin_delete_attendance', ['attendance_id' => $attendance->id]) }}" name="delete-attendance-btn"> Delete </a>
</td>
</tr>
@endforeach
</table>
@else
<p> No attendance data yet. </p>
@endif
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,35 @@
@extends('layouts.adminpanel')
@section('title') Admin Panel - Classes @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
@if ($classes->count() > 0)
<h5> All classes: ({{ $classes->count() }}) </h5>
<table>
<tr>
<th>ID</th>
<th> Subject id </th>
<th> Date </th>
<th> Creation date </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>
<a href="{{ route('admin_delete_classes', ['classes_id' => $classes_item->id]) }}" name="delete-classes-btn"> Delete </a>
</td>
</tr>
@endforeach
</table>
@else
<p> No classes yet. </p>
@endif
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,38 @@
@extends('layouts.adminpanel')
@section('title') Admin Panel - Rooms @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
@if ($rooms->count() > 0)
<h5> All rooms: ({{ $rooms->count() }}) </h5>
<table>
<tr>
<th>ID</th>
<th> Name </th>
<th> Capacity </th>
<th> Arrangement </th>
<th> Creation date </th>
</tr>
@foreach ($rooms as $room)
<tr>
<td> {{ $room->id }}</td>
<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>
</td>
</tr>
@endforeach
</table>
@else
<p> No rooms yet. </p>
@endif
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,40 @@
@extends('layouts.adminpanel')
@section('title') Admin Panel - Subjects @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
@if ($subjects->count() > 0)
<h5> All subjects: ({{ $subjects->count() }}) </h5>
<table>
<tr>
<th>ID</th>
<th> Name </th>
<th> Type </th>
<th> User id </th>
<th> Room id </th>
<th> Creation date </th>
</tr>
@foreach ($subjects as $subject)
<tr>
<td> {{ $subject->id }}</td>
<td> {{ $subject->name }} </td>
<td> {{ $subject->type }} </td>
<td> {{ $subject->user_id}}</td>
<td> {{ $subject->room_id}}</td>
<td> {{ $subject->created_at }} </td>
<td>
<a href="{{ route('admin_delete_subject', ['subject_id' => $subject->id]) }}" name="delete-subject-btn"> Delete </a>
</td>
</tr>
@endforeach
</table>
@else
<p> No subjects yet. </p>
@endif
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,44 @@
@extends('layouts.adminpanel')
@section('title') Admin Panel - Users @endsection
@section('admin_content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
@if ($users->count() > 0)
<h5> All users: ({{ $users->count() }}) </h5>
<table>
<tr>
<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>
</tr>
@foreach ($users as $user)
<tr>
<td> {{ $user->id }}</td>
<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>
</td>
@endif
</tr>
@endforeach
</table>
@else
<p> No users yet. </p>
@endif
</div>
</div>
</div>
@endsection

View File

@ -28,7 +28,7 @@
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="surname" class="col-md-4 col-form-label text-md-right">{{ __('Surame') }}</label> <label for="surname" class="col-md-4 col-form-label text-md-right">{{ __('Surname') }}</label>
<div class="col-md-6"> <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" autofocus>

View File

@ -20,14 +20,14 @@
@endif @endif
</div> </div>
<div class="card-body"> <div class="card-body">
<a href="{{ route('home') }}"> Users </a> <a href="{{ route('admin_users') }}"> Users </a>
<a href="{{ route('home') }}"> Subjects </a> <a href="{{ route('admin_subjects') }}"> Subjects </a>
<a href="{{ route('home') }}"> Rooms </a> <a href="{{ route('admin_rooms') }}"> Rooms </a>
<a href="{{ route('home') }}"> Classes </a> <a href="{{ route('admin_classes') }}"> Classes </a>
<a href="{{ route('home') }}"> Attendances </a> <a href="{{ route('admin_attendances') }}"> Attendances </a>
</div> </div>
<div class="card-body"> <div class="card-body">
@yield('content') @yield('admin_content')
</div> </div>
</div> </div>
@endif @endif

View File

@ -16,3 +16,11 @@ use Illuminate\Http\Request;
Route::middleware('auth:api')->get('/user', function (Request $request) { Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user(); return $request->user();
}); });
Route::post('/card_details', function (Request $request) {
$name = $request->input('name');
$surname = $request->input('surname');
$id_number = $request->input('id_number');
return array('name' => $name, 'surname' => $surname, 'id_number' => $id_number );
});

View File

@ -22,3 +22,26 @@ Auth::routes();
Route::get('/home', 'HomeController@index')->name('home'); Route::get('/home', 'HomeController@index')->name('home');
Route::get('/admin', 'AdminPanelController@index')->name('admin'); Route::get('/admin', 'AdminPanelController@index')->name('admin');
Route::group(array('prefix' => '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('/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', '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');
});