Help! Register Idea, unable to implement!
Using Laravel Livewire
Teacher - select the teacher of the class Month - select the month of intended Year - select the year of the intended
Below is the register table where all information of their attendance will be kept, the only problem is is that I have no idea on how to do it without making it hugely complicated.
Here is what I have now:
@foreach($students as $student)
<tr>
<th scope="row">{{$student->name}}</th>
@for($i=1;$i<=$days;$i++)
<td>
<div class="form-check">
<input class="form-check-input" type="checkbox" wire:click="addAttendanceDate('{{$student->id}}', '{{$i}}')">
</div>
</td>
@endfor
</tr>
@endforeach
public function addAttendanceDate($studentId, $day)
{
$attendance = new Attendance;
$attendance->student_id = $studentId;
$attendance->teacher_id = $this->teacherId;
$attendance->day = $day;
$attendance->month = $this->month;
$attendance->year = $this->year;
$attendance->save();
}
Now I can add it into the db table, but now its just figuring how to get it back out.
I guess I could use something like:
public function populateTable($teacher, $month, $year)
{
$attendance = Attendance::where($teacher = $teacher and $month = month and $year = year);
}
Okay... Ill go down this route which I have mentioned and see where it will take me. But my question is, is this the right road, is there an easier way.
Please or to participate in this conversation.