diff --git a/src/Preset.php b/src/Preset.php index 41cb375..1811ef8 100644 --- a/src/Preset.php +++ b/src/Preset.php @@ -19,6 +19,7 @@ public static function install() static::updateTemplates(); static::removeNodeModules(); static::updateGitignore(); + static::addMacros(); } protected static function updatePackageArray(array $packages) @@ -75,4 +76,9 @@ protected static function updateGitignore() { copy(__DIR__.'/stubs/gitignore-stub', base_path('.gitignore')); } + + protected static function addMacros() + { + copy(__DIR__.'/stubs/app/Providers/AppServiceProvider.php', base_path('app/Providers/AppServiceProvider.php')); + } } diff --git a/src/stubs/app/Providers/AppServiceProvider.php b/src/stubs/app/Providers/AppServiceProvider.php new file mode 100644 index 0000000..e01247a --- /dev/null +++ b/src/stubs/app/Providers/AppServiceProvider.php @@ -0,0 +1,35 @@ +setUri($this->uri() . '.{_format?}'); + }); + + Request::macro('match', function ($responses, $defaultFormat = 'html') { + return value(array_get($responses, $this->route()->parameter('_format', $this->format($defaultFormat)), function () { + abort(404); + })); + }); + } + /** + * Register any application services. + * + * @return void + */ + public function register() + { + // + } +} \ No newline at end of file