lednerb/nova-text-linked-field

Laravel Nova custom Text Field with a link to a resource or custom URL

v1.1.0 2022-04-05 20:21 UTC

This package is auto-updated.

Last update: 2024-11-06 02:18:23 UTC


README

Packagist Version Packagist Downloads

This package is an enhanced version of the original nikans/text-linked field with additional features:

  • open links in new tabs / targets
  • trim functionality with nova tooltip support

NB: The field is compatible to the original one, if you plan to change to this package you only have to update the imports.

Nova custom Text Field with a link to a resource (or any URL) on index screen.

Nova links ID fields to a resource by default. The custom field is useful if you're using a text ID field or want to link a resource's title, as shown below.

Nova TextLinked Field Example

The field behaves just like the default text field on detail and form screens.

Installation

composer require lednerb/nova-text-linked-field

Usage options

Automatically link a resource to a title or text ID field

use Lednerb\TextLinked\TextLinked;

...

TextLinked::make('Title', 'title')
    ->link($this),
    
TextLinked::make('ID')
    ->link($this),

Link a resource by uriKey and id

TextLinked::make('Title', 'title')
    ->linkResource($this->uriKey(), $this->id),

Add a random URL

TextLinked::make('ID')
    ->url("https://novapackages.com"),

Open the link in a new tab or target

TextLinked::make('Title', 'title')
    ->link($this)
    ->openInNewTab(),

TextLinked::make('Title', 'title')
    ->link($this)
    ->openInNewTab('myTarget'), 

Trim long values to a specific amount of chars

Nova TextLinked Field Trim Functionality

TextLinked::make('Title', 'title')
    ->link($this)
    ->trim(), // Default are 50 chars

TextLinked::make('Title', 'title')
    ->link($this)
    ->trim(60), 

By default a tooltip will be shown on hover state with the full untrimed value. If you don't want the tooltip, you can disable it as follows:

TextLinked::make('Title', 'title')
    ->link($this)
    ->trim()
    ->hideTooltip(),