mardi 11 septembre 2018

override laravel 5.7 autodiscovered package routes

I am having trouble allowing users to override my package routes. Because the package is auto discovered, I am unable to do the usual fix for this.

The desired result is if in the routes->web.php a user defines route '/home', and in my package's routes.php file I also have '/home', the web.php version is used.

Let me know what other code I need to be looking at to solve this!

Package Service Provider:

class WoodpeckerServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
     public function boot(\Illuminate\Routing\Router $router)
     {
         $this->loadViewsFrom(base_path('resources/views/windfallInc/woodpecker'), 'woodpecker');
         $this->publishes([
        __DIR__.'/views' => base_path('resources/views'),
        __DIR__.'/less' => base_path('resources/assets/less'),
        __DIR__.'/controller' => base_path('app/Http/Controllers'),
        __DIR__.'/Models' => base_path('app'),
        __DIR__.'/migrations' => base_path('database/migrations'),
        __DIR__.'/Middleware' => base_path('app/Http/Middleware'),
        __DIR__.'/Notifications' => base_path('app/Notifications'),
        __DIR__.'/assets' => base_path('public'),
        __DIR__.'/config' => base_path('config'),
    ]);
        $router->aliasMiddleware('dashboard', \App\Http\Middleware\RedirectIfNotDashboard::class);
        $router->aliasMiddleware('dashboard.guest', \App\Http\Middleware\RedirectIfDashboard::class);
        $this->app->register('WindfallInc\Woodpecker\WoodpeckerRouteServiceProvider');
        Schema::defaultStringLength(191);
     }
    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
        include __DIR__.'/routes.php';
       $this->app->make('WindfallInc\Woodpecker\WoodpeckerController');
    }
}

Package Composer.json:

{
    "name": "windfallinc/woodpecker",
    "description": "This is a package for things and stuff",
    "type": "library",
    "homepage": "https://github.com/WindfallInc/woodpecker",
    "license": "MIT",
    "authors": [
        {
            "name": "Andrew",
            "email": "andrew@windfallstudio.com",
            "homepage": "http://www.walshwebworks.com",
            "role": "Developer"
        }
    ],
    "minimum-stability": "stable",
    "require": {
      "php": ">=7.0.0"
    },
    "autoload": {
        "psr-4": {
            "WindfallInc\\Woodpecker\\": "src/",
        }
    },
    "extra": {
      "laravel": {
        "providers": [
          "WindfallInc\\Woodpecker\\WoodpeckerServiceProvider"
        ]
      }
    }
}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2x8VBBg
via IFTTT

Aucun commentaire:

Enregistrer un commentaire