I'm new to Laravel 5 middleware - and I just recently added a new user type
== Dev
into my application. I need to set a certain route restriction for that user type - in term of what they can/can't access.
So I create
DevMiddleware.php
<?php
namespace App\Http\Middleware;
use App\Article;
use Closure, View ;
use Illuminate\Contracts\Auth\Guard;
class DevMiddleware
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->getUser()->type !== "Dev") {
return View::make('errors.404');
}
return $next($request);
}
}
I registered it in my
Kernel.php
'dev' => 'App\Http\Middleware\DevMiddleware',
I use it in my
Routes.php
$router->group(['middleware' => ['auth', 'admin', 'dev' ] ], function() {
//Any routes goes in here
});
When I go those route in there - keep getting 404 error.
I want to be able to go to those routes.
What did I do wrong here ? How do I fix it ?