Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages
N

model link field

Readme

nova-model-link-field

Search models and append links to this models by nova field

This field allow to fill database "link" column with link to Application Model

Scenario You have 4 models Product, Category, Blog, Order and also you have model Post with fields "name", 'link' .... You want have post with attached link to Product or Category etc.. In normal way, you have to create product_id or category_id ... But you only need link. Thats why this field comes in. You can attach link to multiple models with search functionality

INSTALLATION

composer require mateusztumatek/nova-model-link-field 

Basic usage

Add NovaIsLinkableContract to your models that should be linkable Example :

class Product extends Model implements NovaIsLinkableContract{

    /**
    * Generate link for nova link field 
    * @return string
    */
    public function novaLink(): string
    {
        return route('products.show', ['product' => $this->id]);
    }
}

And in your resource file

    public function fields(NovaRequest $request)
        {
            return [                                          
                NovaModelLinkField::make('Link', 'link')
            ];
        }

If you want keep relative path to your application url you can use

NovaModelLinkField::make('Link', 'link')->storeType('relative')

Screenshots

Back to Top
Added 3 years ago
Last updated 3 Years Ago
Version 1.0.1
Nova Version ~4.0
Composer
mateusztumatek/nova-model-link-field
GitHub stars 1
Packagist downloads 20

Favorites

1 user favorited

Rating

N/A
(out of 5)
★★★★★
★★★★
★★★
★★
0 ratings

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas