PHP code example of khodakhah / laravel-inertia-form
1. Go to this page and download the library: Download khodakhah/laravel-inertia-form 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/ */
khodakhah / laravel-inertia-form example snippets
use Khodakhah\InertiaForm\InertiaFormRequest;
class UserFormRequest extends InertiaFormRequest
{
public static function formInputs(\Khodakhah\InertiaForm\InertiaForm $form) : \Khodakhah\InertiaForm\InertiaForm{
$form->text('name', '
class UserController extends Controller
{
use Khodakhah\InertiaForm\InertiaFormRequest;
public function create()
{
return Inertia::render('User/Create', [
'form' => UserFormRequest::toInertia()
]);
}
public function store(UserFormRequest $request)
{
User::create($request->validated());
return redirect()->route('users.index');
}
}
class UserController extends Controller
{
use Khodakhah\InertiaForm\InertiaForm;
use Illuminate\Http\Request;
private function userForm(): InertiaForm
{
$form = new InertiaForm();
$form->text('name', '$this->userForm()->toInertia()
]);
}
public function store(Request $request)
{
User::create(
$request->validate(
$this->userForm()->toValidation()
)
);
return redirect()->route('users.index');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.