Fullcalendar is not displaying specific user's events in blade
Hello, I have been stuck with this problem for a while now. I am using fullcalendar to display a specific user's event. I have three tables which are Students, Supervisors, and ReflectiveJournals. As for now, the students can see their own event when they are logged in to their own account.
What I want is once the Supervisor has logged in, they can view the student's journals (events) on the calender which is only the students that are currently their supervisee. My problem is that the supervisor is unable to view any of their supervisees' journals (events) on the calendar. The calendar is displaying fine, just that there is no event at all in it.
Here is the blade for the page that should redirect the user to the calendar page, the supervisor will be redirected to the calendar page once they clicked 'View':
<table class="table table-bordered">
<thead>
<tr>
<th style="width: 10px; text-align: center;">#</th>
<th style="text-align: center;"> Student's Name</th>
<th style="width: 180px; text-align: center">Student's ID</th>
<th style=" width: 120px; text-align: center">Action</th>
</tr>
</thead>
<tbody>
@foreach($students as $student)
<tr>
<td>{{$loop->iteration}}</td>
<td>{{$student->name}}</td>
<td>{{$student->matrix_num}}</td>
<td style="text-align: center;">
<a href="/svJournals/{{$student->id}}">View</a>
</td>
</tr>
@endforeach
</tbody>
</table>
Here is my route, web.php:
Route::get('/svJournals/{id}', [ReflectiveJournalController::class, 'svindex']);
Route::get('/journalList', [SupervisorController::class, 'studentList']);
Here is the svindex() function in the ReflectiveJournalController:
public function svindex(Request $request, $id)
{
if ($request->ajax()) {
$data = DB::table('reflective_journals')->where('student_id', '=', $id)->get();
return response()->json($data)->with('sID', $id);
}
return view("Supervisors.supervisorjournal")->with(array('header' => '<h1>Reflective Journal </h1>'))->with('sID', $id);
}
And here is my fullcalendar code:
<script>
$(document).ready(function() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var calendar = $('#calendar').fullCalendar({
editable: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
events: '/svJournals/{{$sID}}',
selectable: true,
selectHelper: true,
dayClick: function(start, end, allDay) {
var selecteddate = start.getDate() + "-" + (start.getMonth() + 1) + "-" + start.getFullYear();
},
select: function(start, end, allDay) {
var title = prompt('Description:');
if (title) {
var start = $.fullCalendar.formatDate(start, 'Y-MM-DD HH:mm:ss');
var end = $.fullCalendar.formatDate(end, 'Y-MM-DD HH:mm:ss');
$.ajax({
url: "{{ route('calendar-action') }}",
type: "POST",
data: {
title: title,
start: start,
end: end,
event_type: 'add'
},
success: function(data) {
calendar.fullCalendar('refetchEvents');
alert("Event Created Successfully");
}
})
}
}
});
</script>
Please or to participate in this conversation.