GithubHelp home page GithubHelp logo

natterhub-ltd / nova-slug-field Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomhatzer/nova-slug-field

0.0 0.0 0.0 282 KB

Slug field for Laravel Nova

License: MIT License

JavaScript 9.40% PHP 35.20% Vue 55.24% SCSS 0.16%

nova-slug-field's Introduction

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.

nova-slug-field's People

Contributors

benjaminhirsch avatar crynobone avatar dennislindsey avatar drobee avatar duckzland avatar joonas1234 avatar nick-f avatar tomhatzer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.