我有以下设置:
In routes I have:
Route::get('articles', 'ArticlesController@index');
控制器中的索引方法很简单:
public function index()
{
$articles = Article::all();
return View('articles.index', compact('articles'));
}
在他们看来:
@extends('../app')
@section('content')
<h1>Articles</h1>
<p>
@foreach($articles as $article)
<article>
<h2><a href="{{action('ArticlesController@show', [$article->id])}}">{{$article->title}}</a></h2>
<p>{{ $article->body }}</p>
</article>
@endforeach
</p>
@stop
我试图替换:
$articles = Article::all();
with
$article = Article::latest()->get();
这样我就可以先展示最新的文章. 我收到错误:
FatalErrorException in Str.php line 322:
Maximum execution time of 30 seconds exceeded
and the call stack is:
in Str.php line 322
at FatalErrorException->__construct() in HandleExceptions.php line 131
at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 116
at HandleExceptions->handleShutdown() in HandleExceptions.php line 0
at Str::snake() in helpers.php line 561
at snake_case() in ControllerInspector.php line 105
at ControllerInspector->getVerb() in ControllerInspector.php line 78
at ControllerInspector->getMethodData() in ControllerInspector.php line 39
at ControllerInspector->getRoutable() in Router.php line 251
at Router->controller() in Router.php line 226
at Router->controllers() in Facade.php line 210
at Facade::__callStatic() in routes.php line 21
at Route::controllers() in routes.php line 21
in RouteServiceProvider.php line 40
... 等
我已将控制器方法恢复到原来的状态,但错误仍然存在.
你能告诉我怎样才能解决这个问题吗?