Skip to content

Commit 7d4511e

Browse files
authored
Merge pull request #37 from simonhamp/feature/nova-4
Nova 4
2 parents 1684d03 + 8b1df2e commit 7d4511e

28 files changed

+791
-417
lines changed

README.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
# Laravel Nova CSV Import
22

3-
[![Latest Stable Version](https://poser.pugx.org/simonhamp/laravel-nova-csv-import/v/stable)](https://packagist.org/packages/simonhamp/laravel-nova-csv-import)
4-
[![Total Downloads](https://poser.pugx.org/simonhamp/laravel-nova-csv-import/downloads)](https://packagist.org/packages/simonhamp/laravel-nova-csv-import)
5-
[![License](https://poser.pugx.org/simonhamp/laravel-nova-csv-import/license)](https://packagist.org/packages/simonhamp/laravel-nova-csv-import)
3+
[![Latest Stable Version](https://poser.pugx.org/simonhamp/laravel-nova-csv-import/v/stable?style=for-the-badge)](https://packagist.org/packages/simonhamp/laravel-nova-csv-import)
4+
[![Total Downloads](https://poser.pugx.org/simonhamp/laravel-nova-csv-import/downloads?style=for-the-badge)](https://packagist.org/packages/simonhamp/laravel-nova-csv-import)
5+
[![License](https://poser.pugx.org/simonhamp/laravel-nova-csv-import/license?style=for-the-badge)](https://packagist.org/packages/simonhamp/laravel-nova-csv-import)
66

7-
A simple CSV import tool for Laravel Nova. This package builds on top of the great work done by Sparclex with the [nova-import-card](https://github.com/Sparclex/nova-import-card) package.
7+
A simple CSV import tool for Laravel Nova that allows you to upload a CSV file via Nova and choose which Nova resource
8+
to import it to.
9+
10+
The import process lets you choose how to map the relevant columns from your uploaded file to the attributes on your
11+
models, with a nice summary at the end of what worked and what didn't
12+
13+
> This package builds on top of the great work done by Sparclex with the [nova-import-card](https://github.com/Sparclex/nova-import-card) package.
814
915
![Laravel Nova CSV Import Screenshot](https://raw.githubusercontent.com/simonhamp/laravel-nova-csv-import/master/screenshots/readme.png)
1016

17+
## Sponsorship
18+
CSV Import is completely free to use. I've built it in my own time to fill my own needs and I also support it in my own
19+
time. If you'd like to show your appreciation for that, I do accept [donations via GitHub](https://github.com/sponsors/simonhamp).
20+
21+
Thank you 🙏
22+
1123
## Installation
1224

1325
Install via Composer:
1426

1527
```bash
16-
composer require simonhamp/laravel-nova-csv-import
28+
composer require simonhamp/laravel-nova-csv-import --with-all-dependencies
1729
```
1830

19-
Once installed, you must register the component in your app's `NovaServiceProvider` (`app/Providers/NovaServiceProvider.php`):
31+
Once installed, you must register the component in your app's `NovaServiceProvider`
32+
(usually in `app/Providers/NovaServiceProvider.php`):
2033

2134
```php
2235
namespace App\Providers;
@@ -35,18 +48,21 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
3548
```
3649

3750
## Options
38-
By default, all of your Nova Resources will be available for import. However, there are a number of ways that you can explicitly limit what's available for importing.
51+
By default, _all_ of your Nova Resources will be available for import. However, there are a number of ways that you can
52+
explicitly limit what's available for importing.
3953

4054
`public static $canImportResource = false;`
4155
*Default:* `true`
4256
Add this static property to your Resource to prevent it from showing up in the Nova CSV Import tool interface.
4357

4458
`public static function canImportResource($request): bool`
45-
Define a `canImportResource` method to use more complex logic to decide if this Resource can be shown during import. If defined, this takes precedence over the `$canImportResource` property.
59+
Define a `canImportResource` method to use more complex logic to decide if this Resource can be shown during import.
60+
If defined, this takes precedence over the `$canImportResource` property.
4661

4762
`public static function excludeAttributesFromImport(): array`
4863
*Default:* `[]`
49-
Define a `excludeAttributesFromImport` method that returns an array of attribute names that you want to _exclude_ from being visible in the import tool for this Resource.
64+
Define a `excludeAttributesFromImport` method that returns an array of attribute names that you want to _exclude_ from
65+
being visible in the import tool for this Resource.
5066

5167

5268
### Example
@@ -65,9 +81,12 @@ public static function excludeAttributesFromImport()
6581
```
6682

6783
## Importer Class
68-
This package uses [maatwebsite/excel](https://github.com/Maatwebsite/Laravel-Excel) behind the scenes to handle the actual import. You can find more information about how importing [works here](https://docs.laravel-excel.com/3.1/imports/basics.html#importing-basics).
84+
This package uses [maatwebsite/excel](https://github.com/Maatwebsite/Laravel-Excel) behind the scenes to handle the
85+
actual import. You can find more information about how importing
86+
[works here](https://docs.laravel-excel.com/3.1/imports/basics.html#importing-basics).
6987

70-
You can define your own importer class by providing the relevant class name in your published copy of this package's config file.
88+
You can define your own importer class by providing the relevant class name in your published copy of this package's
89+
config file.
7190

7291
First, publish the config file:
7392
```

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"license": "MIT",
99
"require": {
1010
"php": ">=7.1.0",
11+
"laravel/nova": "^4.0",
1112
"maatwebsite/excel": "^3.1"
1213
},
1314
"autoload": {

dist/css/tool.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

dist/js/tool.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mix-manifest.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"/js/tool.js": "/js/tool.js"
3-
}
2+
"/js/tool.js": "/js/tool.js",
3+
"/css/tool.css": "/css/tool.css"
4+
}

mix.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const mix = require('laravel-mix')
2+
const webpack = require('webpack')
3+
const path = require('path')
4+
5+
class NovaExtension {
6+
name() {
7+
return 'nova-extension'
8+
}
9+
10+
register(name) {
11+
this.name = name
12+
}
13+
14+
webpackConfig(webpackConfig) {
15+
webpackConfig.externals = {
16+
vue: 'Vue',
17+
}
18+
19+
webpackConfig.resolve.alias = {
20+
...(webpackConfig.resolve.alias || {}),
21+
'laravel-nova': path.join(
22+
__dirname,
23+
'../../vendor/laravel/nova/resources/js/mixins/packages.js'
24+
),
25+
}
26+
27+
webpackConfig.output = {
28+
uniqueName: this.name,
29+
}
30+
}
31+
}
32+
33+
mix.extend('nova', new NovaExtension())

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"private": true,
3-
"scripts": {
4-
"dev": "npm run development",
5-
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6-
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7-
"watch-poll": "npm run watch -- --watch-poll",
8-
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9-
"prod": "npm run production",
10-
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11-
},
12-
"devDependencies": {
13-
"cross-env": "^5.0.0",
14-
"laravel-mix": "^1.0"
15-
},
16-
"dependencies": {
17-
"vue": "^2.5.0"
18-
}
2+
"private": true,
3+
"scripts": {
4+
"dev": "npm run development",
5+
"development": "mix",
6+
"watch": "mix watch",
7+
"watch-poll": "mix watch -- --watch-options-poll=1000",
8+
"hot": "mix watch --hot",
9+
"prod": "npm run production",
10+
"production": "mix --production"
11+
},
12+
"devDependencies": {
13+
"@vue/compiler-sfc": "^3.2.22",
14+
"laravel-mix": "^6.0.41",
15+
"postcss": "^8.3.11",
16+
"vue-loader": "^16.8.3"
17+
},
18+
"dependencies": {}
1919
}

resources/css/tool.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Nova Tool CSS */

resources/js/components/Preview.vue

Lines changed: 0 additions & 181 deletions
This file was deleted.

resources/js/components/Review.vue

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)