#Fix the construct spelling
You need to make it public function __construct(){}, and check your construct spelling, its obvious but you might missed it in first place.
Public access modifier is also needed. Try that and see the outcome. Check here to confirm it.
dd('die')
, I've run the code and that's the one blocking, because of the flow of the code.#Why remove dd('die')
The idea of auth is to prevent unauthenticated user from seeing the page. By using dd('die'), you just show the whole page to the unauthenticated user! The flow of the code is interrupted!
public function __construct(){
$this->middleware('auth');
}
#How to solve?
Use proper 'return' technique, such as this code, or add that dd('die') into the index function:
public function index(){
return view('index.blade.php');
}
Or if it is not working, do this workaround.
Have you register your 'auth' middleware inside App\Kernel?
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
....
];
https://laravel.com/docs/5.3/middleware#registering-middleware
Try to use the normal way to cast your middleware, by casting it inside your web.php
and see if it is working first hand:
Route::get('/your-route', 'AdvertController@index')->middleware('auth');
Cheers.
@XavierIV, thanks, It was the construct spelling mistake, I cant believe i misspelled it, i checked everything a million times but didnt catch the spelling mistake
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\xampp\htdocs\projectsite\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php on line 462 i have the same problem .i am installing microweber which is a multi-featured extendable open source content management system based on the robust Laravel Framework.can anyone help.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community