I have the following set up:
In routes I have:
Route::get('articles', 'ArticlesController@index');
The index method in the controller is simply:
public function index()
{
$articles = Article::all();
return View('articles.index', compact('articles'));
}
and in the view:
@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
I attempted to replace the:
$articles = Article::all();
with
$article = Article::latest()->get();
such that I can actually show the articles latest first.
I got the error:
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
... etc
I have restored the controller method to what it was, but the error persists.
Can you please tell me how I can solve this problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…