我添加了幾個模型和一個控制器。Laravel5.1雄辯慢動作
控制器
論壇:
public function showCategory($alias)
{
$page_title = trans('forum.forum').' :: '.trans('static.website_title');
$category_info = ForumCategory::where('category_alias', $alias)->first();
return view('layout.pages.forum.category', compact('category_info'));
}
模式
ForumCategory
public function threads()
{
return $this->hasMany('App\Forum\ForumThread', 'category_id');
}
ForumThread
public function posts()
{
return $this->hasMany('App\Forum\ForumPost', 'thread_id');
}
category.blade.php:
@extends('layout.default')
@section('content')
{{ $category_info->category_alias }}
{{--*/ $ThreadList = $category_info->threads()->paginate(20) /*--}}
@foreach($ThreadList as $thread)
{{--*/ $a = $thread->posts->count() /*--}}
<a href="{{URL::to('/forum', array($category_info->category_alias, $thread->thread_alias))}}">{{ $thread->thread_id }} - {{ $thread->thread_subject }} - {{ $a }}</a><br /><br />
@endforeach
@stop
頁繪製時間:〜0.701548814774秒。 在我看來,我認爲是非常緩慢...... 我如何加快速度?
在dev上安裝https://github.com/barryvdh/laravel-debugbar讓你知道爲什麼它很慢。 – ceejayoz