File tree Expand file tree Collapse file tree 4 files changed +24
-2
lines changed
Expand file tree Collapse file tree 4 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ return [
4+ 'route_form_prefix ' => '' ,
5+ 'route_redirect_prefix ' => '' ,
6+ ];
Original file line number Diff line number Diff line change 33Route::group (
44 [
55 'middleware ' => ['web ' ],
6+ 'prefix ' => config ('shorturl.route_form_prefix ' ),
67 ],
78 function () {
89 Route::get ('/ ' , 'Gallib\ShortUrl\Http\Controllers\UrlController@create ' )->name ('shorturl.url.create ' );
910 Route::post ('/ ' , 'Gallib\ShortUrl\Http\Controllers\UrlController@store ' )->name ('shorturl.url.store ' );
10- Route::get ('/{code} ' , 'Gallib\ShortUrl\Http\Controllers\RedirectController@redirect ' )->name ('shorturl.redirect ' );
1111 }
1212);
13+
14+ Route::group (
15+ [
16+ 'middleware ' => ['web ' ],
17+ 'prefix ' => config ('shorturl.route_redirect_prefix ' ),
18+ ],
19+ function () {
20+ Route::get ('/{code} ' , 'Gallib\ShortUrl\Http\Controllers\RedirectController@redirect ' )->name ('shorturl.redirect ' );
21+ }
22+ );
Original file line number Diff line number Diff line change @@ -29,9 +29,11 @@ public function rules()
2929 $ uniqueCode .= ',id, ' .$ this ->get ('id ' );
3030 }
3131
32+ $ codeNotIn = config ('shorturl.route_form_prefix ' ) ? '|not_in: ' .config ('shorturl.route_form_prefix ' ) : '' ;
33+
3234 return [
3335 'url ' => 'required|url ' ,
34- 'code ' => 'max:255 ' .$ uniqueCode ,
36+ 'code ' => 'max:255 ' .$ uniqueCode. $ codeNotIn ,
3537 ];
3638 }
3739
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ public function boot()
1818 if ($ this ->app ->runningInConsole ()) {
1919 $ this ->loadMigrationsFrom (__DIR__ .'/../database/migrations ' );
2020
21+ $ this ->publishes ([
22+ __DIR__ .'/../config/shorturl.php ' => config_path ('shorturl.php ' ),
23+ ], 'shorturl-config ' );
24+
2125 $ this ->publishes ([
2226 __DIR__ .'/../resources/views ' => base_path ('resources/views/vendor/shorturl ' ),
2327 ], 'shorturl-views ' );
You can’t perform that action at this time.
0 commit comments