there is a lesson model
public function teacher() { return $this->hasMany(LessonTeacher::class, 'lesson_id'); }
And a model with LessonTeacher tutors
public function lesson() { return $this->belongsTo(Lesson::class,'id'); }
I enter the date and the teacher in the form and send an AJAX request to the controller. I want to know if the teacher is busy on the date the user entered into the form. There are no problems with the date, but there is an error with the teacher search
Method Illuminate\Database\Eloquent\Collection::teacher does not exist
Request itself
$check_lesson_date = Lesson::where(function($query) use ($date_start) { return $query->where('date_start', '<=', $date_start)->where('date_end', '>=', $date_start); }) ->orWhere(function($query) use ($date_end) { return $query->where('date_start', '<=', $date_end)->where('date_end', '>=', $date_end); }) ->get(); $check_teacher = $check_lesson_date->teacher()->where('teacher', $teacher)->count();
Tell me what I'm doing wrong and how to make a request.