https://github.com/lednerb/nova-text-linked-field
Laravel Nova custom Text Field with a link to a resource or custom URL
https://github.com/lednerb/nova-text-linked-field
Last synced: 3 months ago
JSON representation
Laravel Nova custom Text Field with a link to a resource or custom URL
- Host: GitHub
- URL: https://github.com/lednerb/nova-text-linked-field
- Owner: Lednerb
- Created: 2022-04-05T17:20:02.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-05T20:30:01.000Z (about 4 years ago)
- Last Synced: 2025-01-20T08:34:56.304Z (over 1 year ago)
- Language: Vue
- Size: 282 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nova TextLinked custom field
[](https://packagist.org/packages/lednerb/nova-text-linked-field)
[](https://packagist.org/packages/lednerb/nova-text-linked-field)
This package is an enhanced version of the original [nikans/text-linked](https://github.com/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](https://github.com/laravel/nova-issues/issues/268)
or want to **link a resource's title**, as shown below.

The field behaves just like the default text field on detail and form screens.
## Installation
```bash
composer require lednerb/nova-text-linked-field
```
## Usage options
### Automatically link a resource to a title or text ID field
```php
use Lednerb\TextLinked\TextLinked;
...
TextLinked::make('Title', 'title')
->link($this),
TextLinked::make('ID')
->link($this),
```
### Link a resource by `uriKey` and `id`
```php
TextLinked::make('Title', 'title')
->linkResource($this->uriKey(), $this->id),
```
### Add a random URL
```php
TextLinked::make('ID')
->url("https://novapackages.com"),
```
### Open the link in a new tab or target
```php
TextLinked::make('Title', 'title')
->link($this)
->openInNewTab(),
TextLinked::make('Title', 'title')
->link($this)
->openInNewTab('myTarget'),
```
### Trim long values to a specific amount of chars

```php
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:
```php
TextLinked::make('Title', 'title')
->link($this)
->trim()
->hideTooltip(),
```