@@ -33,7 +33,8 @@ final class User extends Authenticatable implements JWTSubject
3333 * @var array
3434 */
3535 protected $ fillable = [
36- 'name ' ,
36+ 'first_name ' ,
37+ 'last_name ' ,
3738 'nickname ' ,
3839 'email ' ,
3940 'password ' ,
@@ -79,13 +80,22 @@ public function setPasswordAttribute($password)
7980 }
8081 }
8182
82- public function changeName (string $ name ): void
83+ public function changeFirstName (string $ firstName ): void
8384 {
84- if (empty ($ name )) {
85- throw new InvalidArgumentException ('User name cannot be empty. ' );
85+ if (empty ($ firstName )) {
86+ throw new InvalidArgumentException ('User first name cannot be empty. ' );
8687 }
8788
88- $ this ->attributes ['name ' ] = $ name ;
89+ $ this ->attributes ['first_name ' ] = $ firstName ;
90+ }
91+
92+ public function changeLastName (string $ lastName ): void
93+ {
94+ if (empty ($ lastName )) {
95+ throw new InvalidArgumentException ('User last name cannot be empty. ' );
96+ }
97+
98+ $ this ->attributes ['last_name ' ] = $ lastName ;
8999 }
90100
91101 public function changeNickName (string $ nickname ): void
@@ -106,9 +116,14 @@ public function changeAvatar(string $avatarUrl): void
106116 $ this ->attributes ['profile_image ' ] = $ avatarUrl ;
107117 }
108118
109- public function getName (): string
119+ public function getFirstName (): string
120+ {
121+ return $ this ->first_name ;
122+ }
123+
124+ public function getLastName (): string
110125 {
111- return $ this ->name ;
126+ return $ this ->last_name ;
112127 }
113128
114129 public function getNickName (): string
0 commit comments