#Make data from AppServiceProvider available to controllers

1 messages · Page 1 of 1 (latest)

graceful oxide
#

What kind of data are you thinking of sharing?

stuck glacier
#

An URL parameter

#

Actually some flag, depending of the value on that parameter

graceful oxide
#

Why don't you just use the request() helper or inject $request into your controller? If you have complex logic you can add a macro to the request class

forest igloo
stuck glacier
# forest igloo Sounds more like a use case for middleware.

I'm trying

Route::group(['middleware' => 'store_middleware'], function () {
    Route::get('/tienda/{store_slug}', [HomeController::class, 'Home']);
});

Then in the middleware within the handle() method the parameter is always null

    public function handle(Request $request, Closure $next): Response
    {
        $slug = $request->get('store_slug');
    }