I have 2 tables employees
and employee_locations
. One employee has many locations. I need to find out one employee record with related latest employee_locations
record. I wrote below query.
$employees = Employee::find([1])->with('employees.employee_locations')->latest()->first();
I am getting below error
BadMethodCallException
Method Illuminate\Database\Eloquent\Collection::with does not exist.