Support the ongoing development of Laravel.io →
Security Requests Architecture
Last updated 1 year ago.
0

#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.

  1. Check spelling
  2. Make the constructor public
  3. Remove 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.

Check if auth is registered

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

Route casting directly from web.php

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.

Last updated 7 years ago.
0

@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

0

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.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.