Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 #88

Open
wants to merge 18 commits into
base: 2.0
Choose a base branch
from
Open

2.0 #88

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions ImportNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Notes for the Nova Import Module (WIP)

Below are two ways of setting up the Import Module. In the first way we will set it up directly on the model we want to import. In the second case we will set it up on a parent model.

### Direct Import
Please follow the basic steps below to make a model importable

- Add the `\Maatwebsite\LaravelNovaExcel\Tools\Import` to your tools
- Add the `BelongsToImport` to your model
- Add the `ImportExcel` action to your resource actions
- Run migrations


### Relational Import
Allow a model to be imported through a relation, you need to follow the steps below

- Add the `\Maatwebsite\LaravelNovaExcel\Tools\Import` to your tools
- Add the `BelongsToImport` to the model you would like to import
- Add the `ImportExcel` action to both the resources, the parent and relation as follows:
- <b>Parent</b>
Before adding the action, make sure to add the following static property to your Parent's resource and replace `{RELATION}` with your relations resource class:
```PHP
public static $import_as = {RELATION}::class;
```
Add the action as below, this will only make it show on the index page:
```PHP
public function actions(Request $request)
{
return [
(new \Maatwebsite\LaravelNovaExcel\Actions\ImportExcel('Import List'))
->onlyOnIndex(true)
];
}
```
It's also possible to add custom meta data using fields which can be used later on after the import as follows:
```PHP
public function actions(Request $request)
{
return [
(new \Maatwebsite\LaravelNovaExcel\Actions\ImportExcel('Import List'))
->onlyOnIndex(true)
->addField(Text::make('name'))
];
}
```
- <b>Relation</b>
Add the action as below, this should hide it also from all the views. The after function isn't required, but is the only way to for example hook the imported models to their parent model, this isn't done automatically because of all the differences in different codebases:
```PHP
public function actions(Request $request)
{
return [
(new \Maatwebsite\LaravelNovaExcel\Actions\ImportExcel())
->visible(false)
->after(function (Collection $models, object $meta) {
// Do stuff after the import with the imported models and meta data
// For example create the parent model and link it to the models from the import
})
];
}
```
14 changes: 14 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Security Policy

**PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, [SEE BELOW](#reporting-a-vulnerability).**

## Supported Versions

Version | Security Fixes Until
--- | ---
1.1 | Active support
1.0 | EOL

## Reporting a Vulnerability

If you discover a security vulnerability within Laravel Excel, please send an email to Patrick Brouwers at [email protected]. All security vulnerabilities will be promptly addressed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function up()
$table->increments('id');
$table->unsignedInteger('user_id')->nullable()->index();
$table->string('resource');
$table->string('parent_resource')->nullable();
$table->string('disk')->nullable();
$table->string('path')->nullable();
$table->string('filename');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function up()
$table->unsignedInteger('upload_id');
$table->unsignedInteger('user_id')->nullable()->index();
$table->string('resource');
$table->string('parent_resource')->nullable();
$table->json('mapping');
$table->string('status')->default('waiting');
//$table->timestamp('undo_at')->nullable();
Expand Down
Loading