vmitchell85/nova-links

Add custom links to your nova navigation

v2.0RC 2022-06-24 02:22 UTC

This package is auto-updated.

Last update: 2022-07-24 02:41:23 UTC


README

Latest Version on Packagist Total Downloads

This tool allows you to add a links section in your sidebar.

alt text

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require vmitchell85/nova-links

Next up, you must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider.

// in app/Providers/NovaServiceProvider.php

// ...

public function tools()
{
    return [
        // ...
        new \vmitchell85\NovaLinks\Links(),
    ];
}

Usage

There are two ways you can add links:

Add Links At Runtime

If you would like to add links at runtime you can add them using the add($linkTitle, $linkUrl, $linkTarget) function like this:

// in app/Providers/NovaServiceProvider.php

// ...

public function tools()
{
    return [
        // ...
        (new \vmitchell85\NovaLinks\Links())
            ->add('Nova Docs', 'https://nova.laravel.com/docs')
            ->add('Laravel Docs', 'https://laravel.com/docs', '_blank'),
    ];
}

Add Links Using the Config File

You can also add links using the config file. First, publish the config file using the following command:

php artisan vendor:publish --provider="vmitchell85\NovaLinks\NovaLinksServiceProvider" --tag="config"

Then open the config file and add your links in the format 'linkName' => 'linkUrl'

// in config/nova-links.php


return [
    'links' => [
        'Nova Docs' => 'http://nova.laravel.com/docs',
        'Laravel Docs' => 'http://laravel.com/docs'
    ],
];

Please note: We do not recommend using this config option with the runtime option. If you have multiple instances and use the config file the config file entries will show on each instance.

Change the Navigation Label

The default heading that will appear in the Nova sidebar is 'Links'.

You can change the navigation label by passing a string to the constructor:

// in app/Providers/NovaServiceProvider.php

// ...

public function tools()
{
    return [
        // ...
        (new \vmitchell85\NovaLinks\Links('Documentation'))
            ->add('Nova Docs', 'https://nova.laravel.com/docs')
            ->add('Laravel Docs', 'https://laravel.com/docs', '_blank'),

        (new \vmitchell85\NovaLinks\Links('News'))
            ->add('Laravel Blog', 'https://blog.laravel.com')
            ->add('Laravel News', 'https://laravel-news.com'),
    ];
}