I have created a middleware to restrict the page going back inside the dashboard as follows:
namespace App\Http\Middleware;
use Closure;
class ValidateBackButton {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
$response->header('Cache-Control','nocache, no-store, max-age=0, must-revalidate')
->header('Pragma','no-cache')
->header('Expires','Sat, 01 Jan 1990 00:00:00 GMT');
return $response;
}
}
I have registered the middleware in app/http/kernel.php
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
'validateback' => 'App\Http\Middleware\ValidateBackButton',
];
I am using the middleware in my controller:
public function __construct()
{
$this->middleware('auth');
$this->middleware('validateback');
}
Everything seems fine, however, i get the following error message:
BadMethodCallException in View.php line 387:
Method [header] does not exist on view.
Kindly help me out!
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1MGvPt0
via IFTTT
Aucun commentaire:
Enregistrer un commentaire