我在 Laravel 7 中使用 php 7.4 创建了全新的项目,并且在用户模型上我具有以下属性:
* The attributes that are mass assignable.
*
* @var array
*/
protected array $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected array $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected array $casts = [
'email_verified_at' => 'datetime',
];
在 Laravel Homestead 上一切正常,但是当我想在 UserSeeder 上使用 Laravel Forge 部署应用程序时,我收到了这条消息:
PHP Fatal error: Type of App\User::$casts must not be defined (as in class Illuminate\Foundation\Auth\User)