2
2
3
3
namespace JamesMills \LaravelTimezone ;
4
4
5
+ use Illuminate \Foundation \AliasLoader ;
5
6
use Illuminate \Support \Facades \Blade ;
6
7
use Illuminate \Support \Facades \Event ;
7
8
use Illuminate \Support \ServiceProvider ;
8
- use Illuminate \Foundation \AliasLoader ;
9
9
use JamesMills \LaravelTimezone \Listeners \Auth \UpdateUsersTimezone ;
10
10
11
11
class LaravelTimezoneServiceProvider extends ServiceProvider
@@ -25,8 +25,13 @@ class LaravelTimezoneServiceProvider extends ServiceProvider
25
25
*/
26
26
public function boot ()
27
27
{
28
- // Register database migrations
29
- $ this ->loadMigrationsFrom (__DIR__ . '/database/migrations ' );
28
+ // Allow migrations publish
29
+ if (! class_exists ('AddTimezoneColumnToUsersTable ' )) {
30
+ $ timestamp = date ('Y_m_d_His ' , time ());
31
+ $ this ->publishes ([
32
+ __DIR__ .'/database/migrations/add_timezone_column_to_users_table.php.stub ' => database_path ("/migrations/ {$ timestamp }_add_timezone_column_to_users_table.php " ),
33
+ ], 'migrations ' );
34
+ }
30
35
31
36
// Register the Timezone alias
32
37
AliasLoader::getInstance ()->alias ('Timezone ' , \JamesMills \LaravelTimezone \Facades \Timezone::class);
@@ -36,7 +41,7 @@ public function boot()
36
41
37
42
// Allow config publish
38
43
$ this ->publishes ([
39
- __DIR__ . '/config/timezone.php ' => config_path ('timezone.php ' ),
44
+ __DIR__ . '/config/timezone.php ' => config_path ('timezone.php ' ),
40
45
], 'config ' );
41
46
42
47
// Register a blade directive to show user date/time in their timezone
@@ -69,4 +74,5 @@ public function register()
69
74
{
70
75
$ this ->app ->bind ('timezone ' , Timezone::class);
71
76
}
77
+
72
78
}
0 commit comments