1

I had this method working before with mysql database but as i have switched my environment to postgresql I got this error.

Facade\Ignition\Exceptions\ViewException

SQLSTATE[HY093]: Invalid parameter number: parameter was not defined 
(SQL: select "teachers".*, "student_likes"."student_id" as "pivot_student_id",
"student_likes"."liked_teacher_id" as "pivot_liked_teacher_id" 
from "teachers" inner join "student_likes" on "teachers"."id" = "student_likes"."liked_teacher_id" 
where "student_likes"."student_id" = 1 and "liked_teacher_id" in (1)) 
(View: /home/leno/sites/schooly/resources/views/student/likes/index.blade.php) 

basically I am trying to perform a match system if both users have liked each other and only display the users if they are a match.

public function matchedTeachers()
    {
        return $this->likedTeachers()->whereIn('liked_teacher_id', $this->likedStudents->keyBy('liked_teacher_id'));
    }

public function likedTeachers()
    {
        return $this->belongsToMany(Teacher::class, 'student_likes', 'student_id', 'liked_teacher_id');
    }
public function likedStudents()
    {
        return $this->belongsToMany(Student::class, 'teacher_likes', 'teacher_id', 'liked_student_id');
    }
@foreach (current_student()->matchedTeachers as $teacher)
    <div class="flex flex-col border hover:shadow-lg border-darkindigo-100 rounded-lg">
      <div class="flex-1 px-3">

        <img src="{{ $teacher->avatar }}" class="block lg:w-20 lg:h-20 rounded-full shadow-xl mx-auto -mt-0 h-20 w-20 bg-cover bg-center object-cover mb-4 mt-4">
        <img src="{{ $teacher->teacher_avatar }}" class="block lg:w-10 lg:h-10 rounded-full border-2 border-teal-400 shadow-xl mx-auto -mt-12 ml-32 h-20 w-20 bg-cover bg-center object-cover mb-4 border:z-10">
        <div class="text-sm lg:text-lg font-lato font-bold text-gray-800 capitalize text-center leading-8">{{ $teacher->name }}</div>
        <div class="text-sm lg:text-sm font-lato font-bold text-gray-700 capitalize text-center">{{ $teacher->language }}</div>
      </div>
    </div>
@endforeach
stef
  • 26,771
  • 31
  • 105
  • 143
seddka
  • 105
  • 12
  • Does this answer your question? [SQLSTATE\[HY093\]: Invalid parameter number: parameter was not defined](https://stackoverflow.com/questions/10966251/sqlstatehy093-invalid-parameter-number-parameter-was-not-defined) – André Walker Aug 28 '20 at 22:48
  • I came across this question earlier but it doesn't seem to answer my question, perhaps I am wrong not having much knowledge about databases. – seddka Aug 28 '20 at 23:10

0 Answers0