<?php namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; class CheckFormSubmission { public function handle(Request $request, Closure $next) { if (!$request->isMethod('post') || !$request->headers->has('content-type') || strpos($request->headers->get('content-type'), 'application/x-www-form-urlencoded') === false) { return response()->view('errors.404', [], 404); } return $next($request); } }