PHP code example of moonlydays / inertia-routed-modals
1. Go to this page and download the library: Download moonlydays/inertia-routed-modals 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/ */
moonlydays / inertia-routed-modals example snippets
use MoonlyDays\InertiaRoutedModals\SharesRoutedModals;
class HandleInertiaRequests extends Middleware
{
use SharesRoutedModals; // add this
public function share(Request $request): array
{
return [
...parent::share($request),
...$this->shareModal(), // add this
// ...
];
}
}
public function action()
{
return Inertia::modal("Component", [
"prop" => "value",
"other" => "value"
]);
}
jsx
import {ModalPortal} from "./ModalPortal";
export function MainLayout({children}) {
return (
<div className="bg-black">
{children}
<ModalPortal/>
</div>
);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.