77use Fleetbase \Notifications \UserCreated ;
88use Fleetbase \Notifications \UserInvited ;
99use Fleetbase \Support \NotificationRegistry ;
10+ use Fleetbase \Support \Timezone ;
1011use Fleetbase \Support \Utils ;
1112use Fleetbase \Traits \ClearsHttpCache ;
1213use Fleetbase \Traits \Expandable ;
@@ -1220,7 +1221,14 @@ public function isNotVerified(): bool
12201221 */
12211222 public static function applyUserInfoFromRequest ($ request , array $ attributes = []): array
12221223 {
1223- $ info = null ;
1224+ $ info = null ;
1225+ $ timezone = Timezone::firstValid ([
1226+ $ request ->input ('timezone ' ),
1227+ $ request ->input ('whois.timezone ' ),
1228+ $ request ->input ('whois.time_zone.name ' ),
1229+ data_get ($ attributes , 'timezone ' ),
1230+ ]);
1231+
12241232 // Lookup user default details
12251233 try {
12261234 $ info = \Fleetbase \Support \Http::lookupIp ($ request );
@@ -1230,10 +1238,16 @@ public static function applyUserInfoFromRequest($request, array $attributes = []
12301238 if ($ info ) {
12311239 $ attributes ['country ' ] = data_get ($ info , 'country_code ' );
12321240 $ attributes ['ip_address ' ] = data_get ($ info , 'ip ' , $ request ->ip ());
1233- $ tzInfo = data_get ($ info , 'time_zone.name ' , $ request ->input ('timezone ' ));
1234- if ($ tzInfo ) {
1235- $ attributes ['timezone ' ] = $ tzInfo ;
1241+ $ timezone = $ timezone ?: Timezone::firstValid ([
1242+ data_get ($ info , 'time_zone.name ' ),
1243+ data_get ($ info , 'timezone ' ),
1244+ data_get ($ info , 'timezone_name ' ),
1245+ ]);
1246+
1247+ if ($ timezone ) {
1248+ $ attributes ['timezone ' ] = $ timezone ;
12361249 }
1250+
12371251 $ attributes ['meta ' ] = [
12381252 'areacode ' => data_get ($ info , 'calling_code ' ),
12391253 'currency ' => data_get ($ info , 'currency.code ' ),
@@ -1245,6 +1259,10 @@ public static function applyUserInfoFromRequest($request, array $attributes = []
12451259 ];
12461260 }
12471261
1262+ if ($ timezone ) {
1263+ $ attributes ['timezone ' ] = $ timezone ;
1264+ }
1265+
12481266 return $ attributes ;
12491267 }
12501268
0 commit comments