我收到错误
方法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');
}
仍然出错。