2019-12-01 19:31:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Http\Request;
|
2019-12-01 23:36:12 +01:00
|
|
|
|
2019-12-01 19:31:49 +01:00
|
|
|
use App\User;
|
|
|
|
use App\Subject;
|
|
|
|
use App\Room;
|
2019-12-01 23:36:12 +01:00
|
|
|
|
2019-12-01 19:31:49 +01:00
|
|
|
|
|
|
|
class AdminSubjectsController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$subjects = Subject::all();
|
|
|
|
$users = User::all();
|
2019-12-06 22:34:25 +01:00
|
|
|
// $rooms = Room::all();
|
|
|
|
$weekdays = ['Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota', 'Niedziela'];
|
|
|
|
// $types = ['Lecture', 'Excercises', 'Labs', 'Other'];
|
|
|
|
return view('admin.admin_subjects', ['subjects' => $subjects, 'users' => $users, 'weekdays' => $weekdays]);
|
2019-12-01 19:31:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function add_subject(Request $request)
|
|
|
|
{
|
|
|
|
$name = $request->input('name');
|
2019-12-06 22:34:25 +01:00
|
|
|
// $type = $request->input('type');
|
2019-12-01 19:31:49 +01:00
|
|
|
$weekday = $request->input('weekday');
|
|
|
|
$time = $request->input('time');
|
2019-12-06 22:34:25 +01:00
|
|
|
// $room_id = $request->input('room_id');
|
2019-12-01 19:31:49 +01:00
|
|
|
$user_id = $request->input('user_id');
|
|
|
|
Subject::create([
|
|
|
|
'name' => $name,
|
2019-12-06 22:34:25 +01:00
|
|
|
// 'type' => $type,
|
2019-12-01 19:31:49 +01:00
|
|
|
'weekday'=> $weekday,
|
|
|
|
'time' => $time,
|
2019-12-06 22:34:25 +01:00
|
|
|
// 'room_id' => $room_id,
|
2019-12-01 19:31:49 +01:00
|
|
|
'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'));
|
|
|
|
}
|
|
|
|
}
|