我使用的是laravel 5.4,下面的代码中有一个错误,
但是在使用laravel 5.3时没有错误,
为什么是这样?
控制器:
public function index()
{
$user=\Auth::user();
$articles=$user->articles;
return view('index', compact('user','articles'));
}视图:
{{ $articles->count() }}错误:
Call to a member function count() on null我该怎么办?
发布于 2017-04-12 16:19:22
Laravel 5.4你应该尝试:
{{ count($articles) }}https://stackoverflow.com/questions/43366399
复制相似问题