我有以下设置:
在我有的路线:
Route :: get('articles','ArticlesController @ index');
控制器中的索引方法很简单:
public function index()
{
$articles = Article::all();
return View('articles.index', compact('articles'));
}
Run Code Online (Sandbox Code Playgroud)
并在视图中:
@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
Run Code Online (Sandbox Code Playgroud)
我试图取代:
$articles = Article::all();
Run Code Online (Sandbox Code Playgroud)
同
$article = Article::latest()->get();
Run Code Online (Sandbox Code Playgroud)
这样我才能真正展示最新的文章.我收到了错误:
FatalErrorException in Str.php line 322:
Maximum execution time of 30 seconds exceeded
Run Code Online (Sandbox Code Playgroud)
并且调用堆栈是:
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 …Run Code Online (Sandbox Code Playgroud)