PHP code example of upline / nova-link-field

1. Go to this page and download the library: Download upline/nova-link-field library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

upline / nova-link-field example snippets


use Upline\NovaLinkField\Link;


class User extends Resource
{
   // ...
   public function fields(NovaRequest $request) 
   {
        return [
            // ...
            Link::make('Instagram')                 // Get link from instagram model field
                ->text(fn() => 'Instagram link')    // Set static anchor 
                ->target('_blank')                  // Set target attribute
        ];   
   }
}

Text::make('Twitter Profile', function () {
    $username = $this->twitterUsername;

    return "<a href='https://twitter.com/{$username}'>@{$username}</a>";
})->asHtml(),  

Link::make('Twitter Profile', function () {
    $username = $this->twitterUsername;
    return "https://twitter.com/{$username}";
})->text('username'),  
shell
use Upline\NovaLinkField\Link;


class User extends Resource
{
   // ...
   public function fields(NovaRequest $request) 
   {
        return [
            // ...
            Link::make('Instagram', fn($resource) => 'https://instagram.com/' . $resource->instagramId) // Compute link
                ->text('instagram_username')    // Use instagram_username field as anchor text 
                ->target('_blank')
        ];   
   }
}