laravel middleware error in middleware parameter

293 views Asked by At

I have a error in my laravel 5 middleware code r following Middleware

use Closure;

 class RoleMiddleware {

/**
 * Handle an incoming request.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @return mixed
 */
public function handle($request, Closure $next,$rr)
{
     echo "Role: ".$rr;

    return $next($request);
}

}

karnel

 <?php namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel {

    /**
     * The application's global HTTP middleware stack.
     *
     * @var array
     */
    protected $middleware = [
        'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
        'Illuminate\Cookie\Middleware\EncryptCookies',
        'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
        'Illuminate\Session\Middleware\StartSession',
        'Illuminate\View\Middleware\ShareErrorsFromSession',
        'App\Http\Middleware\VerifyCsrfToken',
    ];

    /**
     * The application's route middleware.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => 'App\Http\Middleware\Authenticate',
        'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
        'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
        'Role' => '\App\Http\Middleware\RoleMiddleware',
    ];

}

test controller

    <?php
 //use View;
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
//namespace a;

 class TestController extends Controller
 {
 public function index()
 {
         echo "<br>Test Controller.";
 }


 }
 ?>

router

  Route::get('role',[
   'middleware' => 'Role:editor',
   'uses' => 'TestController@index',
]);

;

it shows the error "ReflectionException in compiled.php line 1029: Class Role:editor does not exist"

Please help.

0

There are 0 answers