PHP code example of marshmallow / live-update

1. Go to this page and download the library: Download marshmallow/live-update 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/ */

    

marshmallow / live-update example snippets


use Marshmallow\LiveUpdate\TextLiveUpdate;

public function fields(NovaRequest $request)
{
    return [
        TextLiveUpdate::make('Name'),
    ];
}

TextLiveUpdate::make('Published At', 'published_at')->type('date');

TextLiveUpdate::make('Reference')->copyable();

TextLiveUpdate::make('Slug')->copyableTo('seo_slug', 'Copy to SEO slug');

TextLiveUpdate::make('Name')->asPlaceholder();

TextLiveUpdate::make('Full Name')
    ->listen('first_name', 'change', function ($value, $attribute, $model, $request) {
        return trim($value . ' ' . $model->last_name);
    });

use Illuminate\Database\Eloquent\Model;
use Marshmallow\LiveUpdate\CopyableActionInterface;

class GenerateReference implements CopyableActionInterface
{
    public function execute(Model $model): ?string
    {
        return 'REF-' . $model->getKey();
    }
}

TextLiveUpdate::make('Reference')
    ->copyableWithAction(
        action: GenerateReference::class,
        icon: 'clipboard',
        target_field_label: 'Reference',
        tooltip: 'Generate a reference',
        when: fn () => true,
    );