我刚刚在这里阅读了 Laravel 5.4 文档的一章
在本章中,要定义范围,只需在 Eloquent 模型方法前面加上scope 即可。在一个例子中,定义了两个作用域方法(scopePopular 和 scopeActive),然后,出现以下代码,以展示作用域的功能
$users = App\User::popular()->active()->orderBy('created_at')->get();
Run Code Online (Sandbox Code Playgroud)
题:
谢谢!