File tree 3 files changed +44
-1
lines changed
3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,16 @@ Instead of adding ``` ShortUrl::routes(); ``` you can call three separates metho
38
38
39
39
this allows you to add middlewares or prefix routes.
40
40
41
+ ### Migration Customization
42
+
43
+ If you are not going to use Short Url's default migrations, you should call the
44
+ ` ShortUrl::ignoreMigrations(); ` method in the ` register ` method of your ` AppServiceProvider ` .
45
+ You may export the default migrations using
46
+
47
+ ```
48
+ php artisan vendor:publish --tag=shorturl-migrations
49
+ ```
50
+
41
51
## Nice!
42
52
43
53
Laravel short url is now set up on your homepage.
Original file line number Diff line number Diff line change 4
4
5
5
class ShortUrl
6
6
{
7
+ /**
8
+ * Indicates if migrations will be run.
9
+ *
10
+ * @var bool
11
+ */
12
+ public static $ runsMigrations = true ;
13
+
7
14
/**
8
15
* Register the routes to create urls.
9
16
*
@@ -49,4 +56,14 @@ public function routes()
49
56
$ this ->manageRoutes ();
50
57
$ this ->redirectRoute ();
51
58
}
59
+
60
+ /**
61
+ * Configure package to not register its migrations.
62
+ *
63
+ * @return static
64
+ */
65
+ public static function ignoreMigrations ()
66
+ {
67
+ static ::$ runsMigrations = false ;
68
+ }
52
69
}
Original file line number Diff line number Diff line change @@ -18,7 +18,11 @@ public function boot()
18
18
$ this ->loadViewsFrom (__DIR__ .'/../resources/views ' , 'shorturl ' );
19
19
20
20
if ($ this ->app ->runningInConsole ()) {
21
- $ this ->loadMigrationsFrom (__DIR__ .'/../database/migrations ' );
21
+ $ this ->registerMigrations ();
22
+
23
+ $ this ->publishes ([
24
+ __DIR__ .'/../database/migrations ' => database_path ('migrations ' ),
25
+ ], 'shorturl-migrations ' );
22
26
23
27
$ this ->publishes ([
24
28
__DIR__ .'/../config/shorturl.php ' => config_path ('shorturl.php ' ),
@@ -34,6 +38,18 @@ public function boot()
34
38
}
35
39
}
36
40
41
+ /**
42
+ * Register migration files.
43
+ *
44
+ * @return void
45
+ */
46
+ protected function registerMigrations ()
47
+ {
48
+ if (ShortUrl::$ runsMigrations ) {
49
+ $ this ->loadMigrationsFrom (__DIR__ .'/../database/migrations ' );
50
+ }
51
+ }
52
+
37
53
/**
38
54
* Register the application services.
39
55
*
You can’t perform that action at this time.
0 commit comments