File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Expand file tree Collapse file tree 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
3838
3939this allows you to add middlewares or prefix routes.
4040
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+
4151## Nice!
4252
4353Laravel short url is now set up on your homepage.
Original file line number Diff line number Diff line change 44
55class ShortUrl
66{
7+ /**
8+ * Indicates if migrations will be run.
9+ *
10+ * @var bool
11+ */
12+ public static $ runsMigrations = true ;
13+
714 /**
815 * Register the routes to create urls.
916 *
@@ -49,4 +56,14 @@ public function routes()
4956 $ this ->manageRoutes ();
5057 $ this ->redirectRoute ();
5158 }
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+ }
5269}
Original file line number Diff line number Diff line change @@ -18,7 +18,11 @@ public function boot()
1818 $ this ->loadViewsFrom (__DIR__ .'/../resources/views ' , 'shorturl ' );
1919
2020 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 ' );
2226
2327 $ this ->publishes ([
2428 __DIR__ .'/../config/shorturl.php ' => config_path ('shorturl.php ' ),
@@ -34,6 +38,18 @@ public function boot()
3438 }
3539 }
3640
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+
3753 /**
3854 * Register the application services.
3955 *
You can’t perform that action at this time.
0 commit comments