A
A
Alexander Ampleev2019-04-18 17:24:59
Laravel
Alexander Ampleev, 2019-04-18 17:24:59

Why doesn't Route::middleware('auth')->group() work?

I'm trying to make the simplest example so that the page is available only for authorized users or redirects to authorization.
Here is the TestsController controller

<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class TestsController extends Controller
{
    public function index()
    {
        dd('closed page');
    }
}

Here are the routes:
Route::get('/', function () {
    return view('welcome');
});

Auth::routes();


Route::middleware('auth')->group(function () {

    Route::get('/home', '[email protected]')->name('home');
    Route::get('secret', 'Admin\[email protected]');

});

In the example that I'm looking at, everything works. There version 5.5. laravel. Maybe a version problem? I have 5.3 - when I try to go to /secret it shows 500

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Vinogradov, 2019-04-18
@Ampleev

because

Route::group([
  'middleware' => 'auth',
], function () {
    Route::get('/home', '[email protected]')->name('home');
    Route::get('secret', 'Admin\[email protected]');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question