Skip to content

Commit f432c3f

Browse files
committed
fix: set property cast for User::$id
User::$id should be 1, not '1'.
1 parent 44f1fef commit f432c3f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Entities/User.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class User extends Entity
4040
* @var array<string, string>
4141
*/
4242
protected $casts = [
43+
'id' => 'integer',
4344
'active' => 'boolean',
4445
'permissions' => 'array',
4546
'groups' => 'array',

src/Models/UserModel.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ protected function saveEmailIdentity(array $data): array
298298
}
299299

300300
// Insert
301-
if ($this->tempUser->id === null) {
301+
// If we use Entity Property Casting ['id' => 'integer'],
302+
// `id` returns 0 when not set.
303+
if ($this->tempUser->id === null || $this->tempUser->id === 0) {
302304
/** @var User $user */
303305
$user = $this->find($this->db->insertID());
304306

0 commit comments

Comments
 (0)