Skip to content

Commit ea5a5ca

Browse files
authored
Make the message shown to users when timezone is set configurable. (#66)
1 parent 9494aac commit ea5a5ca

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ By default, the date format will be `jS F Y g:i:a`. To override this configurati
137137

138138
This lookup array configuration makes it possible to find the remote address of the user in any attribute inside the Laravel `request` helper, by any key. Having in mind when the key is found inside the attribute, that key will be used. By default, we use the `server` attribute with the key `REMOTE_ADDR`. To override this configuration, you just need to change the `lookup` property inside the configuration file `config/timezone.php` for the desired lookup.
139139

140+
### User Message
141+
142+
You may configure the message shown to the user when the timezone is set by changing the `message` property inside the configuration file `config/timezone.php`
143+
140144
### Underlying GeoIp Package
141145

142146
If you wish to customise the underlying `torann/geoip` package you can publish the config file by using the command below.

src/Listeners/Auth/UpdateUsersTimezone.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
class UpdateUsersTimezone
1111
{
12-
1312
/**
1413
* Handle the event.
1514
*
@@ -69,7 +68,7 @@ private function notify(Location $geoip_info)
6968
return;
7069
}
7170

72-
$message = 'We have set your timezone to ' . $geoip_info['timezone'];
71+
$message = sprintf(config('timezone.message', 'We have set your timezone to %s'), $geoip_info['timezone']);
7372

7473
if (config('timezone.flash') == 'laravel') {
7574
request()->session()->flash('success', $message);
@@ -140,7 +139,7 @@ private function lookup($type, $keys)
140139
$value = null;
141140

142141
foreach ($keys as $key) {
143-
if (!request()->$type->has($key)) {
142+
if (! request()->$type->has($key)) {
144143
continue;
145144
}
146145
$value = request()->$type->get($key);

src/config/timezone.php

+12
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,16 @@
5959
],
6060
],
6161

62+
/*
63+
|--------------------------------------------------------------------------
64+
| User Message
65+
|--------------------------------------------------------------------------
66+
|
67+
| Here you may configure the message shown to the user when the timezone is set.
68+
| Be sure to include the %s which will be replaced by the detected timezone.
69+
| e.g. We have set your timezone to America/New_York
70+
|
71+
*/
72+
73+
'message' => 'We have set your timezone to %s',
6274
];

0 commit comments

Comments
 (0)