Column relationships dot syntax not working
Why is students.[column] not working? I am getting this error: "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'students.student_no' in 'order clause'
SELECT * FROM
pending_email_student_portals
ORDER BY students
.student_no
ASC limit 10 OFFSET 0"
ListPendingEmailStudentPortal.php:
Students table:
[first pic]
PendingEmailStudentPortals table:
[second pic]
PendingEmailStudentPortal model:


Solution:Jump to solution
Thanks, I changed the relationship to BelongsTo then added ->sortable() to the student_no column.
4 Replies
Student model:
I am not sure but I think because of
hasMany()
relationship. If you query then you'll get array in relationship, not object. but not sure thoPendingEmailStudentPortal to student Rs should be like this I think u need to learn about laravel Model relationship
Solution
Thanks, I changed the relationship to BelongsTo then added ->sortable() to the student_no column.