我想在 Laravel 5.7 中注册一个新的全局作用域,但出现以下错误:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError(E_PARSE)语法错误,意外'静态'(T_STATIC)
<?php
namespace App;
use Auth;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Order extends Model
{
use SoftDeletes;
/**
* Anonymous scope
*/
protected static function boot()
{
parent::boot();
static::addGlobalScope('authenticated', function (Builder $builder) {
$builder->where('id_user', '=', Auth::id());
});
}
}
我正在使用 laravel 5.7 PHP 7.2