digital-creative/resource-navigation-link

Create links to internal or external resources.

Fund package maintenance!
milewski

v1.0.5 2024-02-09 14:44 UTC

This package is auto-updated.

Last update: 2024-10-09 16:09:40 UTC


README

Latest Version on Packagist Total Downloads License

This package is very similar to the https://github.com/dcasia/resource-navigation-tab (visually they are identical) however internally they works differently.

The main difference is that this package is a Card (not a field), and it links to other resources instead of filtering the current resource

Installation

You can install the package via composer:

composer require digital-creative/resource-navigation-link

Basic Usage

use DigitalCreative\ResourceNavigationLink\ResourceNavigationLink;
use DigitalCreative\ResourceNavigationLink\Link;
use Laravel\Nova\Http\Requests\NovaRequest;

class User extends Resource {

    public function cards(NovaRequest $request): array
    {
        return [
            ResourceNavigationLink::make([
                Link::toResourceIndex(User::class),
                Link::toResourceIndex(Article::class),
                Link::toLens(Article::class, MostViewed::class),
                Link::toExternalUrl('Documentation', 'https://laravel.com/docs/10.x/readme'),
            ]),
        ];
    }

}

/**
 * Optional: if you want to copy the navigation links from another resource
 */
class Article extends Resource {

    public function cards(NovaRequest $request): array
    {
        return [
            ...ResourceNavigationLink::copyFromResource(User::class),
        ];
    }

}

⭐️ Show Your Support

Please give a ⭐️ if this project helped you!

Other Packages You Might Like

License

The MIT License (MIT). Please see License File for more information.