PHP code example of idf / nova-unlayer-field

1. Go to this page and download the library: Download idf/nova-unlayer-field 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/ */

    

idf / nova-unlayer-field example snippets


use InteractionDesignFoundation\NovaUnlayerField\Unlayer;

public function fields()
{
    return [
        Unlayer::make('Content', 'design')->config([
            'projectId' => config('unlayer.project_id'),

            // optional
            'templateId' => config('unlayer.default_template_id'), // Used only if bound attribute ('design' in this case) is empty.
            'displayMode' => 'web', // "email" or "web". Default value: "email"
            'locale' => 'es', // Locale for Unlayer UI. Default value: application’s locale.
        ]),
     ];
}

Unlayer::make('Design')->config([
        'projectId' => config('unlayer.project_id'),
    ])
    ->savingCallback(function (NovaRequest $request, $attribute, Newsletter $newsletterModel, $outputHtmlFieldName) {
        // set output HTML to your model (Newsletter in this case)
        // No need to call $model->save() — Nova will do it down the road.
        $newsletterModel->html = $request->input($outputHtmlFieldName);
    }),
sh
php artisan vendor:publish --provider="InteractionDesignFoundation\NovaUnlayerField\ServiceProvider" --tag=config