我有这样的功能秀:
public function show($post)
{
$post = Post::whereId($post)->filter(\Request::only(['fields']))->firstOrFail();
return Response::json($post);
}
如何添加此功能sortBy('我发送的表格中的某些字段')
答案 0 :(得分:0)
只是做:
$post = Post::whereId($post)->filter(\Request::only(['fields']))->orderBy('desired_field','ASC')->firstOrFail();