未定义的属性:标准类::$profession



我在尝试访问 API 时遇到错误异常。 我似乎可以访问 api 中除专业字段以外的所有列。 下面是我在视图中的代码。

</thead>
<tbody>
@foreach ($teachers as $teacher)
<tr>
<td>{{$teacher->id}}</td>
<td>{{$teacher->name}}</td>
<td>{{$teacher->address}}</td>
<td>{{$teacher->profession}}</td>
</tr>
@endforeach
</tbody>

我编写了一个具有以下代码的教师控制器。

public function getAllTeachers()
{
$teachers = $this->obtainAllStudents();
return view('teachers.all-teachers', ['teachers' => $teachers]);
}

这继承自客户端控制器,该控制器作为以下函数为教师检索所有数据。

protected function obtainAllTeachers()
{
return      $this>performGetRequest('https://lumenapi.juandmegon.com/teachers');
}

我认为您正在使用这个:

$teachers = $this->obtainAllStudents();

取而代之的是:

$teachers = $this->obtainAllTeachers();

最新更新