├── dist ├── css │ └── field.css └── js │ └── field.js ├── resources ├── sass │ └── field.scss └── js │ ├── field.js │ └── components │ ├── IndexField.vue │ └── DetailField.vue ├── index-view.png ├── detail-view.png ├── mix-manifest.json ├── .gitignore ├── webpack.mix.js ├── composer.json ├── src ├── ExternalUrl.php └── FieldServiceProvider.php ├── package.json └── readme.md /dist/css/field.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/sass/field.scss: -------------------------------------------------------------------------------- 1 | // Nova Tool CSS 2 | -------------------------------------------------------------------------------- /index-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdewit/nova-external-url/HEAD/index-view.png -------------------------------------------------------------------------------- /detail-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdewit/nova-external-url/HEAD/detail-view.png -------------------------------------------------------------------------------- /mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/dist/js/field.js": "/dist/js/field.js", 3 | "/dist/css/field.css": "/dist/css/field.css" 4 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /vendor 3 | /node_modules 4 | package-lock.json 5 | composer.phar 6 | composer.lock 7 | phpunit.xml 8 | .phpunit.result.cache 9 | .DS_Store 10 | Thumbs.db 11 | -------------------------------------------------------------------------------- /resources/js/field.js: -------------------------------------------------------------------------------- 1 | Nova.booting((Vue, router) => { 2 | Vue.component('index-external-url', require('./components/IndexField')); 3 | Vue.component('detail-external-url', require('./components/DetailField')); 4 | }) 5 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | let mix = require('laravel-mix') 2 | 3 | mix.js('resources/js/field.js', 'dist/js') 4 | .sass('resources/sass/field.scss', 'dist/css') 5 | .webpackConfig({ 6 | resolve: { 7 | symlinks: false 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pdewit/nova-external-url", 3 | "description": "An external URL Laravel Nova field.", 4 | "keywords": [ 5 | "laravel", 6 | "nova" 7 | ], 8 | "license": "MIT", 9 | "require": { 10 | "php": ">=7.1.0" 11 | }, 12 | "autoload": { 13 | "psr-4": { 14 | "Pdewit\\ExternalUrl\\": "src/" 15 | } 16 | }, 17 | "extra": { 18 | "laravel": { 19 | "providers": [ 20 | "Pdewit\\ExternalUrl\\FieldServiceProvider" 21 | ] 22 | } 23 | }, 24 | "config": { 25 | "sort-packages": true 26 | }, 27 | "minimum-stability": "dev", 28 | "prefer-stable": true 29 | } 30 | -------------------------------------------------------------------------------- /src/ExternalUrl.php: -------------------------------------------------------------------------------- 1 | exceptOnForms(); 21 | } 22 | 23 | public function linkText($linkText) { 24 | return $this->withMeta(["linkText" => $linkText]); 25 | } 26 | 27 | public function labelText($labelText) { 28 | return $this->withMeta(["labelText" => $labelText]); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/FieldServiceProvider.php: -------------------------------------------------------------------------------- 1 | 2 |
—
12 |
8 |
9 | And in the index view like this:
10 |
11 |
12 |
13 | ## Installation and usage
14 |
15 | You can require this package using composer:
16 |
17 | ```
18 | composer require pdewit/nova-external-url
19 | ```
20 |
21 | You can add the field with a resolver as follows:
22 |
23 | ```php
24 | use Pdewit\ExternalUrl\ExternalUrl;
25 |
26 | ExternalUrl::make('Google Link', function () {
27 | return 'https://www.google.com/search?q=' . $this->name;
28 | }),
29 | ```
30 |
31 | ## Customising the displayed text
32 |
33 | You can customise the displayed text using the `linkText` function like so:
34 |
35 | ```php
36 | use Pdewit\ExternalUrl\ExternalUrl;
37 |
38 | ExternalUrl::make('Google Link', function () {
39 | return 'https://www.google.com/search?q=' . $this->name;
40 | })->linkText($this->name),
41 | ```
42 |
43 | The label below the link normally shows the URL, but it can be overridden:
44 |
45 | ```php
46 | use Pdewit\ExternalUrl\ExternalUrl;
47 |
48 | ExternalUrl::make('Google Link', function () {
49 | return 'https://www.google.com/search?q=' . $this->name;
50 | })->labelText('View search results on Google'),
51 | ```
52 |
--------------------------------------------------------------------------------
/resources/js/components/DetailField.vue:
--------------------------------------------------------------------------------
1 |
2 | —
14 | 15 |