[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Response.php
<?php namespace Inertia; use Closure; use Illuminate\Support\Arr; use Illuminate\Support\Str; use Inertia\Support\Header; use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\App; use GuzzleHttp\Promise\PromiseInterface; use Illuminate\Support\Traits\Macroable; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Contracts\Support\Responsable; use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\ResourceResponse; use Illuminate\Support\Facades\Response as ResponseFactory; class Response implements Responsable { use Macroable; protected $component; protected $props; protected $rootView; protected $version; protected $viewData = []; /** * @param array|Arrayable $props */ public function __construct(string $component, array $props, string $rootView = 'app', string $version = '') { $this->component = $component; $this->props = $props instanceof Arrayable ? $props->toArray() : $props; $this->rootView = $rootView; $this->version = $version; } /** * @param string|array $key * * @return $this */ public function with($key, $value = null): self { if (is_array($key)) { $this->props = array_merge($this->props, $key); } else { $this->props[$key] = $value; } return $this; } /** * @param string|array $key * * @return $this */ public function withViewData($key, $value = null): self { if (is_array($key)) { $this->viewData = array_merge($this->viewData, $key); } else { $this->viewData[$key] = $value; } return $this; } public function rootView(string $rootView): self { $this->rootView = $rootView; return $this; } /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * * @return \Symfony\Component\HttpFoundation\Response */ public function toResponse($request) { $props = $this->resolvePartialProps($request, $this->props); $props = $this->resolveAlwaysProps($props); $props = $this->evaluateProps($props, $request); $page = [ 'component' => $this->component, 'props' => $props, 'url' => Str::start(Str::after($request->fullUrl(), $request->getSchemeAndHttpHost()), '/'), 'version' => $this->version, ]; if ($request->header(Header::INERTIA)) { return new JsonResponse($page, 200, [Header::INERTIA => 'true']); } return ResponseFactory::view($this->rootView, $this->viewData + ['page' => $page]); } /** * Resolve the `only` and `except` partial request props. */ public function resolvePartialProps(Request $request, array $props): array { $isPartial = $request->header(Header::PARTIAL_COMPONENT) === $this->component; if (! $isPartial) { return array_filter($props, static function ($prop) { return ! ($prop instanceof LazyProp); }); } $only = array_filter(explode(',', $request->header(Header::PARTIAL_ONLY, ''))); $except = array_filter(explode(',', $request->header(Header::PARTIAL_EXCEPT, ''))); $props = $only ? Arr::only($props, $only) : $props; if ($except) { Arr::forget($props, $except); } return $props; } /** * Resolve `always` properties that should always be included on all visits, * regardless of "only" or "except" requests. */ public function resolveAlwaysProps(array $props): array { $always = array_filter($this->props, static function ($prop) { return $prop instanceof AlwaysProp; }); return array_merge( $always, $props ); } /** * Resolve all necessary class instances in the given props. */ public function evaluateProps(array $props, Request $request, bool $unpackDotProps = true): array { foreach ($props as $key => $value) { if ($value instanceof Closure) { $value = App::call($value); } if ($value instanceof LazyProp) { $value = App::call($value); } if ($value instanceof AlwaysProp) { $value = App::call($value); } if ($value instanceof PromiseInterface) { $value = $value->wait(); } if ($value instanceof ResourceResponse || $value instanceof JsonResource) { $value = $value->toResponse($request)->getData(true); } if ($value instanceof Arrayable) { $value = $value->toArray(); } if (is_array($value)) { $value = $this->evaluateProps($value, $request, false); } if ($unpackDotProps && str_contains($key, '.')) { Arr::set($props, $key, $value); unset($props[$key]); } else { $props[$key] = $value; } } return $props; } }
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