pdewit / nova-external-url

An external URL Laravel Nova field.
31 stars 6 forks source link

Laravel Nova 4 support #13

Open Kreshnik opened 2 years ago

Kreshnik commented 2 years ago

Is there support for Laravel Nova 4 planned?

stefblokdijk commented 2 years ago

In case it doesn't gets updated, you could easily replicate this package with the Laravel\Nova\Fields\Text field.

In your resource:

Text::make('Link', function () {

        return view('nova.fields.external-url', [
            'url' => 'https://google.com',
            'text' => 'Search',
            'subtitle' => 'google.com',
        ])->render();

    })
    ->asHtml()
    ->exceptOnForms(),

resources/views/nova/fields/external-url.blade.php:

<div>
    <a class="link-default" href="{{ $url }}" target="_blank">
        <div class="flex items-center">
            <svg class="fill-current mr-1" height="15" width="15" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M576 14.4l-.174 163.2c0 7.953-6.447 14.4-14.4 14.4H528.12c-8.067 0-14.56-6.626-14.397-14.691l2.717-73.627-2.062-2.062-278.863 278.865c-4.686 4.686-12.284 4.686-16.971 0l-23.029-23.029c-4.686-4.686-4.686-12.284 0-16.971L474.379 61.621l-2.062-2.062-73.626 2.717C390.626 62.44 384 55.946 384 47.879V14.574c0-7.953 6.447-14.4 14.4-14.4L561.6 0c7.953 0 14.4 6.447 14.4 14.4zM427.515 233.74l-24 24a12.002 12.002 0 0 0-3.515 8.485V458a6 6 0 0 1-6 6H54a6 6 0 0 1-6-6V118a6 6 0 0 1 6-6h301.976c10.691 0 16.045-12.926 8.485-20.485l-24-24A12.002 12.002 0 0 0 331.976 64H48C21.49 64 0 85.49 0 112v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V242.225c0-10.691-12.926-16.045-20.485-8.485z"></path></svg>
            <span class="leading-none">{{ $text }}</span>
        </div>
        @isset($subtitle)
            <span class="text-xs font-normal no-underline leading-none text-gray-400" >{{ $subtitle }}</span>
        @endisset
    </a>
</div>
Kreshnik commented 2 years ago

Thank you @stefblokdijk, that was very helpful!