我有 2 张桌子employees
和employee_locations
. 一名员工有许多地点。我需要找出一条员工记录以及相关的最新employee_locations
记录。我写了下面的查询。
$employees = Employee::find([1])->with('employees.employee_locations')->latest()->first();
我得到以下错误
BadMethodCallException
Method Illuminate\Database\Eloquent\Collection::with does not exist.