PHP code example of outerweb / nova-link-picker

1. Go to this page and download the library: Download outerweb/nova-link-picker 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/ */

    

outerweb / nova-link-picker example snippets


return [
    'link_entity' => \Outerweb\NovaLinkPicker\Entities\Link::class,
    'api_base_url' => '/nova-vendor/outerweb/nova-link-picker',
    'available_options' => [
        'open_in_new_tab' => true,
        'download' => true,
    ]
];


use Outerweb\NovaLinkPicker\Casts\LinkPickerCast;

...

protected $casts = [
    'link' => LinkPickerCast::class,
];



// Returns the route name as a string
// The routeName value can come from your applications registered routes
// or from the fixed options when it starts with `external.`:
// - `external.url` for an external url
// - `external.mailto` for a mailto link
// - `external.tel` for a tel link
$link->routeName;

// Returns the parameters as an array
$link->parameters;

// Returns the options as an array
$link->options;

// Generate the route (just like you would do with Laravel's `route()` helper)
$link->route();

// Get the target attribute value for the link
$link->target();

// Check if the link is an external link
$link->isExternal();

// Check if the link should be a download link
$link->isDownload();

// Render the link attributes (`href`, `target` and optionally `download`)
// Example: <a {{ $link->renderAttributes() }}>Click me!</a>
$link->renderAttributes();



Route::get('my-route', function () {
    // ...
})->name('my-route')
    ->where('nova-link-picker', 'true');



Route::get('my-route', function () {
    // ...
})->name('my-route')
    ->where('nova-link-picker', 'true')
    ->where('nova-link-picker-label', __('My custom label'));


use Outerweb\NovaLinkPicker\Nova\Fields\LinkPicker;

...

public function fields(Request $request)
{
    return [
        LinkPicker::make('Link')
            // This will Str::limit() the value on the Nova index table
            ->abbreviated()
            // This will hide the `download` option
            ->withoutDownload()
            // This will hide the `open in new tab` option
            ->withoutOpenInNewTab(),
    ];
}


namespace App\Nova\Fields;

use Outerweb\NovaLinkPicker\Nova\Fields\LinkPicker as BaseLinkPicker;

class LinkPicker extends BaseLinkPicker
{
    // Your custom code here
}



namespace App\Entities;

use Outerweb\NovaLinkPicker\Entities\Link as BaseLink;

class Link extends BaseLink
{
    // Your custom code here
}

bash
php artisan vendor:publish --tag="nova-link-picker-config"