未定义的属性:stdClass :: $ profession

时间:2017-07-17 21:57:18

标签: api laravel-5.4 guzzlehttp

尝试访问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]);
}

这继承自ClientController,它作为以下函数检索教师的所有数据。

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

1 个答案:

答案 0 :(得分:1)

我认为你正在使用它:

$teachers = $this->obtainAllStudents();

而不是:

$teachers = $this->obtainAllTeachers();