PHP code example of jessegall / inertia-static-props
1. Go to this page and download the library: Download jessegall/inertia-static-props library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use JesseGall\InertiaStaticProps\StaticProp;
use Inertia\Inertia;
class HandleInertiaRequests extends Middleware
{
public function share(Request $request): array
{
return [
...parent::share($request),
// Using a StaticProp instance
'translations' => new StaticProp(fn() => $this->resolveTranslations()),
// Using the Inertia helper
'enums' => Inertia::static(fn() => $this->resolveEnums()),
];
}
}
class LocaleController extends Controller
{
public function update(...)
{
// Something that