atcheck/app/Http/Controllers/Admin/AdminSubjectsController.php

56 lines
1.5 KiB
PHP
Raw Normal View History

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();
// $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');
// $type = $request->input('type');
2019-12-01 19:31:49 +01:00
$weekday = $request->input('weekday');
$time = $request->input('time');
// $room_id = $request->input('room_id');
2019-12-01 19:31:49 +01:00
$user_id = $request->input('user_id');
Subject::create([
'name' => $name,
// 'type' => $type,
2019-12-01 19:31:49 +01:00
'weekday'=> $weekday,
'time' => $time,
// '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'));
}
}