New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

benjaminhirsch/nova-slug-field

A Laravel Nova field to generate a slugs.
1,174,566 140
Install
composer require benjaminhirsch/nova-slug-field
Latest Version:1.4.0
PHP:>=7.1.0
License:MIT
Last Updated:Dec 27, 2023
Links: GitHub  ·  Packagist
Maintainer: tomhatzer

Laravel Nova Slug Field

Simple Laravel Nova Slug field. Generating a slugified version of a text input. See the result of the slug while typing.

Edit form

details page select

Installation

In order to use this package, you need a Laravel installation which uses Nova.

Composer

composer require benjaminhirsch/nova-slug-field

Usage

Define the following fields in your resource in the fields method:

use Benjaminhirsch\NovaSlugField\Slug;
use Benjaminhirsch\NovaSlugField\TextWithSlug;

...

TextWithSlug::make('Name')
    ->slug('slug'),

Slug::make('Slug'),
Slug with a preview of the generated URL

This will display the full URL including the generated slug as a link below the input field.

use Benjaminhirsch\NovaSlugField\Slug;
use Benjaminhirsch\NovaSlugField\TextWithSlug;

...

TextWithSlug::make('Name')
    ->slug('slug'),

Slug::make('Slug')
    ->showUrlPreview('http://www.foo.bar'),
Slug with disabled auto update

This is especially usefull, when you are updating the field which the slug belongs to and don't wan't the slug to be updated automatically.

use Benjaminhirsch\NovaSlugField\Slug;
use Benjaminhirsch\NovaSlugField\TextWithSlug;

...

TextWithSlug::make('Name')
    ->slug('slug'),

Slug::make('Slug')
    ->disableAutoUpdateWhenUpdating(),

This first field definition is the field which you want to create the slug of. The second field definition represents the slugified version. With the ->slug('name') method, you define the name of the field which holds the slug. It is possible to create multiple slugs on a single resource, just add more field definitions. Every TextWithSlug field needs a corresponding Slug field.

Related Packages

epartment/nova-dependency-container

A Laravel Nova field container allowing to depend on other fields values

4,703,233 378
eminiarts/nova-tabs

Laravel Nova - Tabs.

4,610,439 464
ebess/advanced-nova-media-library

Laravel Nova tools for managing the Spatie media library.

3,888,853 616
spatie/nova-tags-field

A tags field for Nova apps

2,356,168 301
kabbouchi/nova-impersonate

A Laravel Nova field allows you to authenticate as your users.

2,268,645 234

Version History

Version Released PHP License
1.4.0 >=7.1.0 MIT
1.3.0 >=7.1.0 MIT
1.2.6 >=7.1.0 MIT
1.2.4 >=7.1.0 MIT
1.2.3 >=7.1.0 MIT