PHP code example of larasell-dev / cushion

1. Go to this page and download the library: Download larasell-dev/cushion 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/ */

    

larasell-dev / cushion example snippets


use App\Models\User;
use Larasell\Cushion\Form;

final class CheckoutForm extends Form
{
    public function fields(): array
    {
        return [
            'company' => 'string|max:255',
            'first_name' => 'string|max:255|ring|max:2|

use App\Http\Forms\CheckoutForm;
use Larasell\Cushion\Form;

Form::add(CheckoutForm::class);

// Some other route
Route::get(/* ... */);

use App\Http\Forms\CheckoutForm;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;

public function show(Request $request): Response
{
    $form = new CheckoutForm($request->user());

    return Inertia::render('checkout', [
        'billing' => $form->hydrate($request->user()),
    ]);
}