Added middleware IsWebsiteTranslations and IsProject.
This fixes errors where Project or WebsiteTranslations are not found.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Services\WebsiteTranslations;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class IsWebsiteTranslations
|
||||
{
|
||||
public function handle(Request $request, \Closure $next): Response
|
||||
{
|
||||
$websiteTranslations = $request->get('websiteTranslations');
|
||||
if (\is_null($websiteTranslations)) {
|
||||
\abort(Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
if ($websiteTranslations instanceof WebsiteTranslations === false) {
|
||||
\report("$websiteTranslations must be an instance of WebsiteTranslations");
|
||||
\abort(Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user