Skip to content

This package allows you to add Laravel Nova field to open the front preview url of a ressource

License

Notifications You must be signed in to change notification settings

novius/laravel-nova-field-preview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Nova Field Preview

License: AGPL v3

Introduction

This package allows you to add Laravel Nova field to open the front preview url of a ressource.

Requirements

  • Laravel Nova >= 4.0
  • Laravel >= 8.0

Installation

You can install the package via composer:

composer require novius/laravel-nova-field-preview

Add OpenPreview field on your Nova Resource.

If the resource have a previewUrl method :

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

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

Otherwise you must specify the preview url :

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';
            }),

Lang files

If you want to customize the lang files, you can publish them with:

php artisan vendor:publish --provider="Novius\LaravelNovaFieldPreview\LaravelNovaFieldPreviewServiceProvider" --tag="lang"

Lint

Lint your code with Laravel Pint using:

composer run-script lint

Licence

This package is under GNU Affero General Public License v3 or (at your option) any later version.

About

This package allows you to add Laravel Nova field to open the front preview url of a ressource

Topics

Resources

License

Stars

Watchers

Forks

Languages