Eine Möglichkeit ist es, die VerifyCsrfToken zu erweitern und eine Reihe von nicht haben csrf Urls innen:
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Session\TokenMismatchException;
class VerifyCsrfToken extends \Illuminate\Foundation\Http\Middleware\VerifyCsrfToken {
protected $except_urls = [
'contact/create',
'contact/update',
...
];
public function handle($request, Closure $next)
{
$regex = '#' . implode('|', $this->except_urls) . '#';
if ($this->isReading($request) || $this->tokensMatch($request) || preg_match($regex, $request->path()))
{
return $this->addCookieToResponse($request, $next($request));
}
throw new TokenMismatchException;
}
}
Und Änderung Kernel die neue Middleware-zu-Punkt:
protected $middleware = [
...
'App\Http\Middleware\VerifyCsrfToken',
];
Sie weitere Details bei dort finden können:
https://laravel.com/docs/5.1/routing#csrf-protection
Laravel 5: POST whithout CSRF checking