【发布时间】:2022-08-14 00:12:15
【问题描述】:
我想知道我们如何获得模型的所有 globalScopes 的列表。
假设我们有这些用于 User 模型的 globalScopes:
class User extends Model
{
use SoftDeletes;
protected static function boot()
{
self::addGlobalScope(new UserTypeScope());
self::addGlobalScope(new UserStatusScope());
}
}
现在我想获取 User 模型的所有 GlobalScopes 的列表。
// I want a way to get the name of that two Scope classes
$scopes = User::getScopes();
// $scopes should have UserTypeScope and UserStatusScope
任何帮助将不胜感激
标签: php laravel builder laravel-9