PHP code example of novius / laravel-nova-field-preview

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

    

novius / laravel-nova-field-preview example snippets


use Laravel\Nova\Resource;
use Novius\LaravelNovaFieldPreview\Nova\Fields\OpenPreview;

class Post extends Resource
{
    protected function fields(): array
    {
        return [
            OpenPreview::make('Preview link'),

use Laravel\Nova\Resource;
use Novius\LaravelNovaFieldPreview\Nova\Fields\OpenPreview;

class Post extends Resource
{
    protected function fields(): array
    {
        return [
            OpenPreview::make('Preview link')
            ->previewUrl(function() {
                // Return here the preview url of the resource
                return $this->resource->url().'.?preview=1';
            }),
bash
php artisan vendor:publish --provider="Novius\LaravelNovaFieldPreview\LaravelNovaFieldPreviewServiceProvider" --tag="lang"