1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-24 15:27:43 +01:00
openstamanager/app/Http/Middleware/HandleInertiaRequests.php
Maicol Battistini d1b3c05255
refactor(backend): ♻️ Refactor generale
Stile codice, sostituiti tipi PHPDoc con i tipi nativi di PHP
2021-08-03 19:43:16 +02:00

50 lines
1.2 KiB
PHP

<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Inertia\Middleware;
use Nette\Utils\Json;
class HandleInertiaRequests extends 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
*/
public function version(Request $request): string|null
{
return parent::version($request);
}
/**
* Defines the props that are shared by default.
*
* @see https://inertiajs.com/shared-data
*/
public function share(Request $request): array
{
return array_merge(parent::share($request), [
'locale' => fn () => app()->getLocale(),
'translations' => function () {
$json = resource_path('lang/'.app()->getLocale().'.json');
if (!file_exists($json)) {
return [];
}
return Json::decode(file_get_contents($json));
},
]);
}
}