chore(auth): improve user model

- use property-read instead of property which prevents property assignment e.g. calling 
  ->save() on a model (Larastan will flag it)
- cast all colums explicitly to avoid wired issues between different DB types
This commit is contained in:
peaklabs-dev 2026-02-24 17:44:29 +01:00
parent beeb7eec69
commit d0562593d6
No known key found for this signature in database

View file

@ -9,13 +9,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
/**
* @property int $id
* @property string $name
* @property string $email
* @property CarbonInterface|null $email_verified_at
* @property string $password
* @property CarbonInterface $created_at
* @property CarbonInterface $updated_at
* @property-read int $id
* @property-read string $name
* @property-read string $email
* @property-read CarbonInterface|null $email_verified_at
* @property-read string $password
* @property-read CarbonInterface $created_at
* @property-read CarbonInterface $updated_at
*/
final class User extends Authenticatable
{
@ -29,7 +29,6 @@ final class User extends Authenticatable
*/
protected $hidden = [
'password',
'remember_token',
];
/**
@ -40,8 +39,13 @@ final class User extends Authenticatable
protected function casts(): array
{
return [
'id' => 'int',
'name' => 'string',
'email' => 'string',
'email_verified_at' => 'datetime',
'password' => 'hashed',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
}
}