如何解决语法错误,意外的 '->' (T_OBJECT_OPERATOR) (0)

how to solve syntax error, unexpected '->' (T_OBJECT_OPERATOR) (0)

<tbody> 
@if(count($articles) > 0)
 @foreach(@articles->all() as $article)

<tr class="table-active">
  <th ></th>
  <td></td>
  <td></td>
  <td>
      <a herf="{{ url('')}}" ><button class="label label-primary">Read |</button></a>
      <a herf="{{ url('')}}" ><button class="label label-success"> Update |</button></a>
      <a herf="{{ url('')}}" ><button class="label label-danger">Delete |</button></a>
  </td>
</tr>
@endforeach
@endif

控制器:

class CreatesController extends Controller
{
    public function home()
    {
        $articles =Article::all();
        return view('home',['article'=>$articles]);
    }
}

出现以下错误。

syntax error, unexpected '->' (T_OBJECT_OPERATOR) (View: C:\xampp\htdocs\laravelcrud\resources\views\home.blade.php)

替换

 @foreach(@articles->all() as $article)

 @foreach($articles as $article)

Return 使用以下语法查看视图

return view('home', compact('articles'));

并将以下内容用于 foreach

@foreach ( $articles as $article ) //your code here @endforeach