方法orderBy在视图中不存在

时间:2016-04-11 13:04:43

标签: php laravel laravel-5 laravel-5.2

我收到错误

  

方法orderBy在我的视图中不存在。

这是我的观点:

@foreach($post->comments->orderBy('created_at', 'desc') as $comment)
    {{ $comment->comments }}
@endforeach
@stop

这是我的控制者:

public function store(Request $request)
{
    $post = new post;

    $post->title = $request->title;
    $post->save();

    return redirect()->route('rules');
}

public function show($title)
{
    $post = post::where('title', $title)->first();

    return view('post.show', compact('post'));
}


public function storecomment(request $request)
{
    $comment = new comment;

    $comment->post_id = Crypt::decrypt(Input::get('post_id'));
    $comment->comments = $request->comments;
    $comment->save();

    return redirect()->route('rules');
}

仍然出错。

0 个答案:

没有答案