Skip to content
This repository was archived by the owner on Sep 18, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static function install()
static::updateTemplates();
static::removeNodeModules();
static::updateGitignore();
static::addMacros();
}

protected static function updatePackageArray(array $packages)
Expand Down Expand Up @@ -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'));
}
}
35 changes: 35 additions & 0 deletions src/stubs/app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
namespace App\Providers;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Support\ServiceProvider;
use App\Http\Middleware\CaptureRequestExtension;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Route::macro('multiformat', function () {
return $this->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()
{
//
}
}