R
R
RMate2019-01-17 11:52:35
Laravel
RMate, 2019-01-17 11:52:35

Laravel, Why doesn't request get into route::group?

Hello!
If you make such a route - everything works as expected

Route::get('/', function (Request $request) {
    dd($request->user());
});

however, this does not happen in the case of a group route.
Route::group(['domain' => '{uid}.localhost'], function () {

  Route::get('/', function (Request $request) {
      dd($request->user());
  }
});

The option to receive through a static object is not suitable, because due to this trouble, the middleware does not work correctly

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Kremenchuk, 2019-01-17
@RMate

You must specify the full path to the class.

Route::group(['domain' => '{uid}.localhost'], function () {
  Route::get('/', function (\Illuminate\Http\Request $request) {
      dd($request);
  });
});

K
Konstantin B., 2019-01-17
@Kostik_1993

I don't know what's wrong, but try with app('request')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question