Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

knubbe's avatar
Level 36

Laravel Forge Deployment fail with php 7.4 typed property on User model

I create fresh new project in Laravel 7 with php 7.4 and on User model I have this properties:

* 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',
    ];

and on Laravel Homestead everything works fine but when I want to deploy app with Laravel Forge on UserSeeder I got this message:

PHP Fatal error:  Type of App\User::$casts must not be defined (as in class Illuminate\Foundation\Auth\User)
0 likes
2 replies
knubbe's avatar
Level 36

My IDE (storm) change vendor HasAttributes trait and set array type to all properties and because of that in local everything works fine. Delete vendor, composer install and return User model to default save my day ;)

2 likes

Please or to participate in this conversation.