@@ -23,11 +23,11 @@ public function __construct(LaravelMixpanel $mixPanel)
23
23
*/
24
24
public function created (Model $ user )
25
25
{
26
- $ firstName = $ user ->first_name ?: '' ;
27
- $ lastName = $ user ->last_name ?: '' ;
26
+ $ firstName = $ user ->getAttribute ( ' first_name ' ) ;
27
+ $ lastName = $ user ->getAttribute ( ' last_name ' ) ;
28
28
29
- if ($ user ->name ) {
30
- $ nameParts = explode (' ' , $ user ->name );
29
+ if ($ user ->getAttribute ( ' name ' ) ) {
30
+ $ nameParts = explode (' ' , $ user ->getAttribute ( ' name ' ) );
31
31
array_filter ($ nameParts );
32
32
$ lastName = array_pop ($ nameParts );
33
33
$ firstName = implode (' ' , $ nameParts );
@@ -36,14 +36,13 @@ public function created(Model $user)
36
36
$ data = [
37
37
'$first_name ' => $ firstName ,
38
38
'$last_name ' => $ lastName ,
39
- '$name ' => $ user ->name ,
40
- '$email ' => $ user ->email ,
39
+ '$name ' => $ user ->getAttribute ('name ' ),
40
+ '$email ' => $ user ->getAttribute ('email ' ),
41
+ '$created ' => ($ user ->getAttribute ('created_at ' )
42
+ ? $ user ->getAttribute ('created_at ' )->format ('Y-m-d\Th:i:s ' )
43
+ : null ),
41
44
];
42
45
43
- if ($ user ->created_at ) {
44
- $ data ['$created ' ] = $ user ->created_at ->format ('Y-m-d\Th:i:s ' );
45
- }
46
-
47
46
array_filter ($ data );
48
47
49
48
$ request = App::make (Request::class);
@@ -57,11 +56,11 @@ public function created(Model $user)
57
56
public function saving (Model $ user )
58
57
{
59
58
$ this ->mixPanel ->identify ($ user ->getKey ());
60
- $ firstName = $ user ->first_name ?: '' ;
61
- $ lastName = $ user ->last_name ?: '' ;
59
+ $ firstName = $ user ->getAttribute ( ' first_name ' ) ;
60
+ $ lastName = $ user ->getAttribute ( ' last_name ' ) ;
62
61
63
- if ($ user ->name ) {
64
- $ nameParts = explode (' ' , $ user ->name );
62
+ if ($ user ->getAttribute ( ' name ' ) ) {
63
+ $ nameParts = explode (' ' , $ user ->getAttribute ( ' name ' ) );
65
64
array_filter ($ nameParts );
66
65
$ lastName = array_pop ($ nameParts );
67
66
$ firstName = implode (' ' , $ nameParts );
@@ -70,14 +69,13 @@ public function saving(Model $user)
70
69
$ data = [
71
70
'$first_name ' => $ firstName ,
72
71
'$last_name ' => $ lastName ,
73
- '$name ' => $ user ->name ,
74
- '$email ' => $ user ->email ,
72
+ '$name ' => $ user ->getAttribute ('name ' ),
73
+ '$email ' => $ user ->getAttribute ('email ' ),
74
+ '$created ' => ($ user ->getAttribute ('created_at ' )
75
+ ? $ user ->getAttribute ('created_at ' )->format ('Y-m-d\Th:i:s ' )
76
+ : null ),
75
77
];
76
78
77
- if ($ user ->created_at ) {
78
- $ data ['$created ' ] = $ user ->created_at ->format ('Y-m-d\Th:i:s ' );
79
- }
80
-
81
79
array_filter ($ data );
82
80
83
81
if (count ($ data )) {
0 commit comments