如何在Laravel5 ORM中一起使用orderBy和where子句

时间:2015-07-22 03:15:49

标签: laravel-5

在laravel5中,我需要将orderBy和where子句放在一起,如:

{{1}}

但是orderBy没有用。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

这是肯定会有效的代码。只需将orderBy放在最后。像:

$patches = Patch::where('AccountID', '=', Auth::user()->AccountID)
->orderBy('PatchCode', 'DESC')
->get();