File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 1212 "require" : {
1313 "php" : " ^8.2" ,
1414 "laravel/framework" : " ^10.44.0 || ^11.0" ,
15- "flagsmith/flagsmith-php-client" : " ^4.2.0 "
15+ "flagsmith/flagsmith-php-client" : " ^4.3.1 "
1616 },
1717 "extra" : {
1818 "laravel" : {
3232 "require-dev" : {
3333 "guzzlehttp/psr7" : " ^2.6.2" ,
3434 "guzzlehttp/guzzle" : " ^7.8.1" ,
35- "orchestra/testbench" : " ^8.22 .0" ,
36- "phpunit/phpunit" : " ^10.5.13 " ,
37- "vimeo/psalm" : " ^5.23.1 " ,
38- "squizlabs/php_codesniffer" : " ^3.9.0 "
35+ "orchestra/testbench" : " ^8.23 .0" ,
36+ "phpunit/phpunit" : " ^10.5.25 " ,
37+ "vimeo/psalm" : " ^5.25.0 " ,
38+ "squizlabs/php_codesniffer" : " ^3.10.1 "
3939 },
4040 "config" : {
4141 "allow-plugins" : {
Original file line number Diff line number Diff line change 22
33namespace Clearlyip \LaravelFlagsmith \Concerns ;
44
5+ use BackedEnum ;
56use Flagsmith \Flagsmith ;
67use Flagsmith \Models \Identity ;
78use Flagsmith \Models \IdentityTrait ;
89use Flagsmith \Utils \Collections \FlagModelsList ;
910use Illuminate \Support \Facades \App ;
11+ use UnitEnum ;
1012
1113trait HasFlags
1214{
@@ -112,7 +114,13 @@ public function getFlagTraits(): array
112114 return array_reduce (
113115 config ('flagsmith.identity.traits ' , []),
114116 function ($ carry , $ attribute ) {
115- $ carry [$ attribute ] = $ this ->getRawOriginal ($ attribute );
117+ $ value = $ this ->{$ attribute };
118+ if ($ value instanceof BackedEnum) {
119+ $ value = $ value ->value ;
120+ } elseif ($ value instanceof UnitEnum) {
121+ $ value = $ value ->name ;
122+ }
123+ $ carry [$ attribute ] = $ value ;
116124 return $ carry ;
117125 },
118126 [],
Original file line number Diff line number Diff line change 44
55use Clearlyip \LaravelFlagsmith \Contracts \UserFlags ;
66use Clearlyip \LaravelFlagsmith \Jobs \SyncUser ;
7+ use Flagsmith \Utils \IdentitiesGenerator ;
78use Illuminate \Auth \Events \Login ;
89
910class UserLogin
@@ -42,8 +43,13 @@ public function handle(Login $event)
4243 return ;
4344 }
4445
46+ $ key = IdentitiesGenerator::generateIdentitiesCacheKey (
47+ $ user ->getFlagIdentityId (),
48+ (object ) $ user ->getFlagTraits (),
49+ );
50+
4551 //Doesn't exist so get it now
46- if (!$ cache ->has (' Identity. ' . $ user -> getFlagIdentityId () )) {
52+ if (!$ cache ->has ($ key )) {
4753 SyncUser::dispatchSync ($ user );
4854 } else {
4955 SyncUser::dispatch ($ user )->onQueue ($ queue );
You can’t perform that action at this time.
0 commit comments