routes fixed
This commit is contained in:
parent
85c8c21ff4
commit
027f788596
@ -4,6 +4,7 @@ namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use App\Subject;
|
||||
use App\Classes;
|
||||
@ -11,8 +12,9 @@ use App\Attendance;
|
||||
|
||||
class UserAttendancesController extends Controller
|
||||
{
|
||||
public function index($user_id, $groupBy)
|
||||
public function index($groupBy='classes_id')
|
||||
{
|
||||
$user_id = Auth::id();
|
||||
$subjects = Subject::where('user_id', $user_id)->get();
|
||||
$subjects_ids = $subjects->pluck('id')->toArray();
|
||||
$classes = Classes::whereIn('subject_id', $subjects_ids)->get();
|
||||
@ -22,7 +24,7 @@ class UserAttendancesController extends Controller
|
||||
return view('user.user_attendances', ['attendances' => $attendances, 'attendances_grouped' => $attendances_grouped, 'classes' => $classes, 'grouped_by' => $groupBy]);
|
||||
}
|
||||
|
||||
public function add_attendance($user_id, Request $request)
|
||||
public function add_attendance(Request $request)
|
||||
{
|
||||
$classes_id = $request->input('classes_id');
|
||||
$student_id_number = $request->input('student_id');
|
||||
@ -36,18 +38,18 @@ class UserAttendancesController extends Controller
|
||||
'student_surname' => $student_surname,
|
||||
'seat_number' => $seat_number,
|
||||
]);
|
||||
return redirect(route('user_attendances', [$user_id, 'classes_id']));
|
||||
return redirect(route('user_attendances'));
|
||||
}
|
||||
|
||||
public function delete_attendance($user_id, $attendance_id, $groupBy)
|
||||
public function delete_attendance($attendance_id)
|
||||
{
|
||||
Attendance::find($attendance_id)->delete();
|
||||
return redirect(route('user_attendances', [$user_id, $groupBy]));
|
||||
return redirect(route('user_attendances'));
|
||||
}
|
||||
|
||||
public function edit_attendance($user_id, $attendance_id, $groupBy)
|
||||
public function edit_attendance($attendance_id)
|
||||
{
|
||||
Attendance::find($attendance_id);
|
||||
return redirect(route('user_attendances', [$user_id, $groupBy]));
|
||||
return redirect(route('user_attendances'));
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,13 @@ use Illuminate\Http\Request;
|
||||
|
||||
use App\Subject;
|
||||
use App\Classes;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UserClassesController extends Controller
|
||||
{
|
||||
public function index($user_id, $groupBy)
|
||||
public function index($groupBy='name')
|
||||
{
|
||||
$user_id = Auth::id();
|
||||
$subjects = Subject::where('user_id', $user_id)->get();
|
||||
$subjects_ids = $subjects->pluck('id')->toArray();
|
||||
$classes = Classes::whereIn('subject_id', $subjects_ids)->get();
|
||||
@ -19,7 +21,7 @@ class UserClassesController extends Controller
|
||||
return view('user.user_classes', ['classes' => $classes, 'classes_grouped' => $classes_grouped, 'subjects' => $subjects, 'grouped_by' => $groupBy]);
|
||||
}
|
||||
|
||||
public function add_classes($user_id, Request $request)
|
||||
public function add_classes(Request $request)
|
||||
{
|
||||
$subject_id = $request->input('subject_id');
|
||||
$date = $request->input('date');
|
||||
@ -27,18 +29,18 @@ class UserClassesController extends Controller
|
||||
'subject_id' => $subject_id,
|
||||
'date' => $date
|
||||
]);
|
||||
return redirect(route('user_classes', [$user_id, 'name']));
|
||||
return redirect(route('user_classes'));
|
||||
}
|
||||
|
||||
public function delete_classes($user_id, $classes_id, $groupBy)
|
||||
public function delete_classes($classes_id)
|
||||
{
|
||||
Classes::find($classes_id)->delete();
|
||||
return redirect(route('user_classes', [$user_id, $groupBy]));
|
||||
return redirect(route('user_classes'));
|
||||
}
|
||||
|
||||
public function edit_classes($user_id, $classes_id, $groupBy)
|
||||
public function edit_classes($classes_id)
|
||||
{
|
||||
Classes::find($classes_id);
|
||||
return redirect(route('user_classes', [$user_id, $groupBy]));
|
||||
return redirect(route('user_classes'));
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,16 @@ namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Subject;
|
||||
use App\Room;
|
||||
|
||||
class UserSubjectsController extends Controller
|
||||
{
|
||||
public function index($user_id, $groupBy)
|
||||
public function index($groupBy='weekday')
|
||||
{
|
||||
$user_id = Auth::id();
|
||||
$subjects = Subject::where('user_id', $user_id)->get();
|
||||
$subjects_grouped = $subjects->groupBy($groupBy);
|
||||
$rooms = Room::all();
|
||||
@ -22,14 +23,14 @@ class UserSubjectsController extends Controller
|
||||
'types' => $types, 'subjects_grouped' => $subjects_grouped, 'grouped_by' => $groupBy]);
|
||||
}
|
||||
|
||||
public function add_subject($user_id, Request $request)
|
||||
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_n = $user_id;
|
||||
$user_id_n = Auth::id();
|
||||
Subject::create([
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
@ -38,18 +39,18 @@ class UserSubjectsController extends Controller
|
||||
'room_id' => $room_id,
|
||||
'user_id' => $user_id_n
|
||||
]);
|
||||
return redirect(route('user_subjects', [$user_id, 'weekday']));
|
||||
return redirect(route('user_subjects'));
|
||||
}
|
||||
|
||||
public function delete_subject($user_id, $subject_id, $groupBy)
|
||||
public function delete_subject($subject_id)
|
||||
{
|
||||
Subject::find($subject_id)->delete();
|
||||
return redirect(route('user_subjects', [$user_id, $groupBy]));
|
||||
return redirect(route('user_subjects'));
|
||||
}
|
||||
|
||||
public function edit_subject($user_id, $subject_id, $groupBy)
|
||||
public function edit_subject($subject_id)
|
||||
{
|
||||
Subject::find($subject_id);
|
||||
return redirect(route('user_subjects', [$user_id, $groupBy]));
|
||||
return redirect(route('user_subjects'));
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,9 @@
|
||||
@endif
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<a href="{{ route('user_subjects', [Auth::user()->id, 'weekday']) }}" class="btn btn-primary"> My subjects </a>
|
||||
<a href="{{ route('user_classes', [Auth::user()->id, 'subject_id']) }}" class="btn btn-primary"> My classes </a>
|
||||
<a href="{{ route('user_attendances', [Auth::user()->id, 'classes_id']) }}" class="btn btn-primary"> Attendance </a>
|
||||
<a href="{{ route('user_subjects', ['weekday']) }}" class="btn btn-primary"> My subjects </a>
|
||||
<a href="{{ route('user_classes', ['subject_id']) }}" class="btn btn-primary"> My classes </a>
|
||||
<a href="{{ route('user_attendances', ['classes_id']) }}" class="btn btn-primary"> Attendance </a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@yield('user_content')
|
||||
|
@ -102,9 +102,9 @@
|
||||
|
||||
<div class="card-body">
|
||||
<span> Group by: </span>
|
||||
<a href="{{ route('user_attendances', [Auth::user()->id, 'classes_id']) }}" class="btn btn-primary"> Classes name </a>
|
||||
<a href="{{ route('user_attendances', [Auth::user()->id, 'student_id_number']) }}" class="btn btn-primary"> Student ID </a>
|
||||
<a href="{{ route('user_attendances', [Auth::user()->id, 'seat_number']) }}" class="btn btn-primary"> Seat number </a>
|
||||
<a href="{{ route('user_attendances', ['classes_id']) }}" class="btn btn-primary"> Classes name </a>
|
||||
<a href="{{ route('user_attendances', ['student_id_number']) }}" class="btn btn-primary"> Student ID </a>
|
||||
<a href="{{ route('user_attendances', ['seat_number']) }}" class="btn btn-primary"> Seat number </a>
|
||||
</div>
|
||||
|
||||
@foreach ($attendances_grouped as $attendances_group_name => $attendances_list)
|
||||
@ -141,10 +141,10 @@
|
||||
<td> {{ $attendance->student_surname}}</td>
|
||||
<td> {{ $attendance->seat_number }} </td>
|
||||
<td>
|
||||
<a href="{{ route('user_delete_attendance', [Auth::user()->id, $attendance->id, 'classes_id']) }}" name="delete-attendance-btn" class="btn btn-danger"> Delete </a>
|
||||
<a href="{{ route('user_delete_attendance', [$attendance->id]) }}" name="delete-attendance-btn" class="btn btn-danger"> Delete </a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('user_edit_attendance', [Auth::user()->id, $attendance->id, 'classes_id']) }}" name="edit-attendance-btn" class="btn btn-secondary"> Edit </a>
|
||||
<a href="{{ route('user_edit_attendance', [$attendance->id]) }}" name="edit-attendance-btn" class="btn btn-secondary"> Edit </a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
@ -57,8 +57,8 @@
|
||||
|
||||
<div class="card-body">
|
||||
<span> Group by: </span>
|
||||
<a href="{{ route('user_classes', [Auth::user()->id, 'subject_id']) }}" class="btn btn-primary"> Subject name </a>
|
||||
<a href="{{ route('user_classes', [Auth::user()->id, 'date']) }}" class="btn btn-primary"> Date </a>
|
||||
<a href="{{ route('user_classes', ['subject_id']) }}" class="btn btn-primary"> Subject name </a>
|
||||
<a href="{{ route('user_classes', ['date']) }}" class="btn btn-primary"> Date </a>
|
||||
</div>
|
||||
|
||||
@foreach ($classes_grouped as $classes_group_name => $classes_list)
|
||||
@ -85,10 +85,10 @@
|
||||
{{ 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('user_delete_classes', [Auth::user()->id, $classes_item->id, 'subject_id']) }}" name="delete-classes-btn" class="btn btn-danger"> Delete </a>
|
||||
<a href="{{ route('user_delete_classes', [$classes_item->id]) }}" name="delete-classes-btn" class="btn btn-danger"> Delete </a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('user_edit_classes', [Auth::user()->id, $classes_item->id, 'subject_id']) }}" name="edit-classes-btn" class="btn btn-secondary"> Edit </a>
|
||||
<a href="{{ route('user_edit_classes', [$classes_item->id]) }}" name="edit-classes-btn" class="btn btn-secondary"> Edit </a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
@ -123,11 +123,11 @@
|
||||
|
||||
<div class="card-body">
|
||||
<span> Group by: </span>
|
||||
<a href="{{ route('user_subjects', [Auth::user()->id, 'name']) }}" class="btn btn-primary"> Name </a>
|
||||
<a href="{{ route('user_subjects', [Auth::user()->id, 'type']) }}" class="btn btn-primary"> Type </a>
|
||||
<a href="{{ route('user_subjects', [Auth::user()->id, 'weekday']) }}" class="btn btn-primary"> Day of the week </a>
|
||||
<a href="{{ route('user_subjects', [Auth::user()->id, 'time']) }}" class="btn btn-primary"> Time </a>
|
||||
<a href="{{ route('user_subjects', [Auth::user()->id, 'room_id']) }}" class="btn btn-primary"> Room </a>
|
||||
<a href="{{ route('user_subjects', ['name']) }}" class="btn btn-primary"> Name </a>
|
||||
<a href="{{ route('user_subjects', ['type']) }}" class="btn btn-primary"> Type </a>
|
||||
<a href="{{ route('user_subjects', ['weekday']) }}" class="btn btn-primary"> Day of the week </a>
|
||||
<a href="{{ route('user_subjects', ['time']) }}" class="btn btn-primary"> Time </a>
|
||||
<a href="{{ route('user_subjects', ['room_id']) }}" class="btn btn-primary"> Room </a>
|
||||
</div>
|
||||
|
||||
@foreach ($subjects_grouped as $subject_group_name => $subjects_list)
|
||||
@ -161,10 +161,10 @@
|
||||
<td> {{ App\User::find($subject->user_id)->name }} {{ App\User::find($subject->user_id)->surname }}</td>
|
||||
<td> {{ App\Room::find($subject->room_id)->name }} </td>
|
||||
<td>
|
||||
<a href="{{ route('user_delete_subject', [Auth::user()->id, $subject->id, 'weekday']) }}" name="delete-subject-btn" class="btn btn-danger"> Delete </a>
|
||||
<a href="{{ route('user_delete_subject', [$subject->id]) }}" name="delete-subject-btn" class="btn btn-danger"> Delete </a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('user_edit_subject', [Auth::user()->id, $subject->id, 'weekday']) }}" name="edit-subject-btn" class="btn btn-secondary"> Edit </a>
|
||||
<a href="{{ route('user_edit_subject', [$subject->id]) }}" name="edit-subject-btn" class="btn btn-secondary"> Edit </a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
@ -49,10 +49,10 @@ Route::group(array('prefix' => 'admin', 'namespace' => 'Admin'), function()
|
||||
});
|
||||
});
|
||||
|
||||
Route::group(array('prefix' => 'user/{user_id}', 'namespace' => 'User'), function() { //TODO poprawic {user_id}
|
||||
Route::get('/subjects/{groupBy}', 'UserSubjectsController@index')->name('user_subjects');
|
||||
Route::get('/classes/{groupBy}', 'UserClassesController@index')->name('user_classes');
|
||||
Route::get('/attendance/{groupBy}', 'UserAttendancesController@index')->name('user_attendances');
|
||||
Route::group(array('prefix' => 'user', 'namespace' => 'User'), function() { //TODO poprawic {user_id}
|
||||
Route::get('/subjects/{groupBy?}', 'UserSubjectsController@index')->name('user_subjects');
|
||||
Route::get('/classes/{groupBy?}', 'UserClassesController@index')->name('user_classes');
|
||||
Route::get('/attendance/{groupBy?}', 'UserAttendancesController@index')->name('user_attendances');
|
||||
|
||||
Route::group(array('prefix' => 'add'), function() {
|
||||
Route::post('/subject', 'UserSubjectsController@add_subject')->name('user_add_subject');
|
||||
@ -61,15 +61,15 @@ Route::group(array('prefix' => 'user/{user_id}', 'namespace' => 'User'), functio
|
||||
});
|
||||
|
||||
Route::group(array('prefix' => 'delete'), function() {
|
||||
Route::get('/subject/{subject_id}/{groupBy}', 'UserSubjectsController@delete_subject')->name('user_delete_subject');
|
||||
Route::get('/classes/{classes_id}/{groupBy}', 'UserClassesController@delete_classes')->name('user_delete_classes');
|
||||
Route::get('/attendance/{attendance_id}/{groupBy}', 'UserAttendancesController@delete_attendance')->name('user_delete_attendance');
|
||||
Route::get('/subject/{subject_id}/{groupBy?}', 'UserSubjectsController@delete_subject')->name('user_delete_subject');
|
||||
Route::get('/classes/{classes_id}/{groupBy?}', 'UserClassesController@delete_classes')->name('user_delete_classes');
|
||||
Route::get('/attendance/{attendance_id}/{groupBy?}', 'UserAttendancesController@delete_attendance')->name('user_delete_attendance');
|
||||
});
|
||||
|
||||
Route::group(array('prefix' => 'edit'), function() {
|
||||
Route::get('/subject/{subject_id}/{groupBy}', 'UserSubjectsController@edit_subject')->name('user_edit_subject');
|
||||
Route::get('/classes/{classes_id}/{groupBy}', 'UserClassesController@edit_classes')->name('user_edit_classes');
|
||||
Route::get('/attendance/{attendance_id}/{groupBy}', 'UserAttendancesController@edit_attendance')->name('user_edit_attendance');
|
||||
Route::get('/subject/{subject_id}/{groupBy?}', 'UserSubjectsController@edit_subject')->name('user_edit_subject');
|
||||
Route::get('/classes/{classes_id}/{groupBy?}', 'UserClassesController@edit_classes')->name('user_edit_classes');
|
||||
Route::get('/attendance/{attendance_id}/{groupBy?}', 'UserAttendancesController@edit_attendance')->name('user_edit_attendance');
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user