【发布时间】:2021-05-29 01:34:55
【问题描述】:
在我的 laravel 项目中,我想为每个新创建的记录设置一个随机默认值。
根据this Doc,我试试这个:
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;
class User extends Authenticatable
{
protected $fillable = [
'access_token'
];
protected $attributes = [
'access_token' => str::uuid()
];
}
但我收到protected $attributes 行的错误
"Constant expression contains invalid operations"
【问题讨论】:
标签: php laravel laravel-5.7