I want to ask, how can I upload a file to the network on user 1, but only attach it to user 1, while currently it is also attached to user 2, my coding is wrong.
Just like the example image below: Picture Network
Take a look at the picture. If it has been uploaded, change its status to Submitted in the "Bahasa Indonesia" SUBJECT. However, for user 2, it has not been uploaded yet, but it has also become Submitted. User 2's status must be Waiting because it has not been uploaded yet. Upload.这里附上我在用户1上上传的mysql: 图像MySqli
AssignmentStudentController
public function DataAssignment(){ $userAssignments = Assignment::join('subjects', 'assignments.id_subject', '=', 'subjects.id_sub') ->join('class_infos', 'subjects.id_class', '=', 'class_infos.id') ->join('class_details', 'class_infos.id', '=', 'class_details.id_class') ->where('class_details.id_user', '=', Auth::user()->id) ->get(); return view('student.assignment.data_assignment', compact('userAssignments')); }
AssignmentStudentController.php
In addition to the assignment method in the model, you can also check by defining a new method:
When using, you can use
!$data->checkStudentAssignmentIsNull()
instead of!empty($data->assignments->id_student)
.I can see your table more clearly now: